Skip to content

Commit

Permalink
Added Fixtures to conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherwin-14 committed Jul 8, 2024
1 parent af1c596 commit 2f7d6a5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def authenticated_store():

# we need to use a valid EDL credential

assert "EARTHDATA_USERNAME" in os.environ is True
assert "EARTHDATA_PASSWORD" in os.environ is True
assert "EARTHDATA_USERNAME" in os.environ
assert "EARTHDATA_PASSWORD" in os.environ

auth = Auth().login(strategy="environment")
assert auth.authenticated is True
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
assertions = unittest.TestCase("__init__")


assertions.assertTrue("EARTHDATA_USERNAME" in os.environ)
assertions.assertTrue("EARTHDATA_PASSWORD" in os.environ)
assert "EARTHDATA_USERNAME" in os.environ
assert "EARTHDATA_PASSWORD" in os.environ

logger.info(f"Current username: {os.environ['EARTHDATA_USERNAME']}")
logger.info(f"earthaccess version: {earthaccess.__version__}")
Expand Down Expand Up @@ -46,13 +46,13 @@ def test_auth_returns_valid_auth_class():
auth = earthaccess.login(strategy="environment")
assertions.assertIsInstance(auth, earthaccess.Auth)
assertions.assertIsInstance(earthaccess.__auth__, earthaccess.Auth)
assertions.assertTrue(earthaccess.__auth__.authenticated)
assert earthaccess.__auth__.authenticated is True


def test_dataset_search_returns_none_with_no_parameters():
results = earthaccess.search_datasets()
assertions.assertIsInstance(results, list)
assertions.assertTrue(len(results) == 0)
assert (len(results) == 0) is True


@pytest.mark.parametrize("kwargs", dataset_valid_params)
Expand All @@ -66,7 +66,7 @@ def test_dataset_search_returns_valid_results(kwargs):
def test_granules_search_returns_valid_results(kwargs):
results = earthaccess.search_data(count=10, **kwargs)
assertions.assertIsInstance(results, list)
assertions.assertTrue(len(results) <= 10)
assert (len(results) <= 10) is True


@pytest.mark.parametrize("selection", [0, slice(None)])
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_auth_can_create_authenticated_requests_sessions():
def test_auth_can_fetch_s3_credentials():
activate_environment()
auth = earthaccess.login(strategy="environment")
assertions.assertTrue(auth.authenticated)
assert auth.authenticated is True
for daac in earthaccess.daac.DAACS:
if len(daac["s3-credentials"]) > 0:
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_cloud_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_earthaccess_can_open_onprem_collection_granules(
# We are testing this method
fileset = store.open(granules_to_open)

assertions.assertTrue(isinstance(fileset, list))
assert isinstance(fileset, list) is True

# we test that we can read some bytes and get the file type
for file in fileset:
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_onprem_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def test_earthaccess_can_download_onprem_collection_granules(
# We are testing this method
downloaded_results = store.get(granules_to_download, local_path=local_path)

assertions.assertTrue(isinstance(downloaded_results, list))
assertions.assertTrue(len(downloaded_results) == granules_sample_size)
assert isinstance(downloaded_results, list) is True
assert (len(downloaded_results) == granules_sample_size) is True

path = Path(local_path)
assertions.assertTrue(path.is_dir())
assert path.is_dir() is True
# test that we downloaded the mb reported by CMR
total_mb_downloaded = round(
(sum(file.stat().st_size for file in path.rglob("*")) / 1024**2), 2
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_onprem_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_earthaccess_can_open_onprem_collection_granules(
total_granules = granule_query.hits()
granules = granule_query.get(granules_count)
assertions.assertTrue(len(granules) > 0, "Could not fetch granules")
assertions.assertTrue(isinstance(granules[0], earthaccess.results.DataGranule))
assert isinstance(granules[0], earthaccess.results.DataGranule) is True
data_links = granules[0].data_links()
if not supported_collection(data_links):
logger.warning(f"PODAAC DRIVE is not supported at the moment: {data_links}")
Expand All @@ -98,7 +98,7 @@ def test_earthaccess_can_open_onprem_collection_granules(
# We are testing this method
fileset = store.open(granules_to_open)

assertions.assertTrue(isinstance(fileset, list))
assert isinstance(fileset, list) is True

# we test that we can read some bytes and get the file type
for file in fileset:
Expand Down

0 comments on commit 2f7d6a5

Please sign in to comment.