feat: Click CLI wrapper for cantaloupe export

- cantaloupe/ package with click CLI (python -m cantaloupe export)
- export command: --output, --headless/--visible, --scheduled, --email, --password
- configure command: saves credentials to ~/.cantaloupe.env (600 perms)
- cantaloupe/config.py: credential loading from env vars + env file
- Updated src/auth.py _get_credentials() to also check ~/.cantaloupe.env
- File size, row count (openpyxl), and elapsed time reporting
- 39 new CLI/config tests + 4 updated auth tests; 86/86 pass
This commit is contained in:
2026-05-21 18:35:34 -04:00
parent b5ae89a490
commit 9c3d3ef7ed
7 changed files with 960 additions and 10 deletions
+12 -8
View File
@@ -34,20 +34,23 @@ def test_get_credentials_from_env():
def test_get_credentials_missing_email():
with patch.dict(os.environ, {"CANTALOUPE_PASSWORD": "pw"}, clear=True):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
with patch("src.auth.os.path.expanduser", return_value="/nonexistent/.cantaloupe.env"):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
def test_get_credentials_missing_password():
with patch.dict(os.environ, {"CANTALOUPE_EMAIL": "u@test.com"}, clear=True):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
with patch("src.auth.os.path.expanduser", return_value="/nonexistent/.cantaloupe.env"):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
def test_get_credentials_none_set():
with patch.dict(os.environ, {}, clear=True):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
with patch("src.auth.os.path.expanduser", return_value="/nonexistent/.cantaloupe.env"):
with pytest.raises(AuthenticationError, match="Credentials not found"):
_get_credentials()
# ─────────────────────────────────────────────────
@@ -230,8 +233,9 @@ def test_login_with_custom_client():
def test_login_missing_credentials():
with patch.dict(os.environ, {}, clear=True):
with pytest.raises(AuthenticationError, match="Credentials not found"):
login()
with patch("src.auth.os.path.expanduser", return_value="/nonexistent/.cantaloupe.env"):
with pytest.raises(AuthenticationError, match="Credentials not found"):
login()
# ─────────────────────────────────────────────────