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:
+12
-8
@@ -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()
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user