Skip to content

Commit

Permalink
Refactored the loop in the tests by parameterzing the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherwin-14 committed Jun 30, 2024
1 parent 9f43047 commit a4c2fe7
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,32 @@ 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', 'provider'),
(
('NSIDC', 'NSIDC_CPRD'),
('GHRCDAAC', 'GHRC_DAAC'),
('PODAAC', 'POCLOUD'),
('ASF', 'ASF'),
('ORNLDAAC', 'ORNL_CLOUD'),
('LPDAAC', 'LPCLOUD'),
('GES_DISC', 'GES_DISC'),
('OBDAAC', 'OB_CLOUD'),
('LAADS', 'LAADS'),
('ASDC', 'LARC_CLOUD'),
)
)
def test_auth_can_fetch_s3_credentials(daac, provider):
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']}")
credentials = earthaccess.get_s3_credentials(daac["short-name"])
assertions.assertIsInstance(credentials, dict)
assertions.assertTrue("accessKeyId" in credentials)
except Exception as e:
logger.error(
try:
logger.info(f"Testing S3 credentials for {daac['short-name']}")
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}"
)

Expand Down

0 comments on commit a4c2fe7

Please sign in to comment.