Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored the loop in the tests by parameterizing #736

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import earthaccess
import pytest
import requests
import s3fs

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -79,21 +80,18 @@ def test_auth_can_create_authenticated_requests_sessions():
assertions.assertTrue("Bearer" in session.headers["Authorization"])


def test_auth_can_fetch_s3_credentials():
@pytest.mark.parametrize("daac", earthaccess.daac.DAACS)
def test_auth_can_fetch_s3_credentials(daac):
activate_environment()
auth = earthaccess.login(strategy="environment")
assertions.assertTrue(auth.authenticated)
for daac in earthaccess.daac.DAACS:
if len(daac["s3-credentials"]) > 0:
try:
logger.info(f"Testing S3 credentials for {daac['short-name']}")
Sherwin-14 marked this conversation as resolved.
Show resolved Hide resolved
credentials = earthaccess.get_s3_credentials(daac["short-name"])
assertions.assertIsInstance(credentials, dict)
assertions.assertTrue("accessKeyId" in credentials)
except Exception as e:
logger.error(
f"An error occured while trying to fetch S3 credentials for {daac['short-name']}: {e}"
)
assert auth.authenticated
try:
credentials = earthaccess.get_s3_credentials(daac["short-name"])
except requests.RequestException as e:
logger.error(f"Failed to fetch S3 credentials: {e}")
else:
assert isinstance(credentials, dict)
assert "accessKeyId" in credentials


@pytest.mark.parametrize("location", ({"daac": "podaac"}, {"provider": "pocloud"}))
Expand Down
Loading