From e06765acd385cd2400bec5c4b74ab4f4e5fb3276 Mon Sep 17 00:00:00 2001 From: Rachel Wegener Date: Mon, 14 Aug 2023 15:30:19 +0000 Subject: [PATCH] remove .netrc creation and update existing tests to new auth method --- icepyx/tests/test_auth.py | 4 ++++ icepyx/tests/test_behind_NSIDC_API_login.py | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/icepyx/tests/test_auth.py b/icepyx/tests/test_auth.py index 8e19ae933..35c48b716 100644 --- a/icepyx/tests/test_auth.py +++ b/icepyx/tests/test_auth.py @@ -8,6 +8,10 @@ @pytest.fixture() def auth_instance(): + ''' + An EarthdatAuthMixin object for each of the tests. Default scope is function + level, so a new instance should be created for each of the tests. + ''' return EarthdataAuthMixin() # Test that .session creates a session diff --git a/icepyx/tests/test_behind_NSIDC_API_login.py b/icepyx/tests/test_behind_NSIDC_API_login.py index cc4275225..a4dff74b2 100644 --- a/icepyx/tests/test_behind_NSIDC_API_login.py +++ b/icepyx/tests/test_behind_NSIDC_API_login.py @@ -20,16 +20,7 @@ def reg(): @pytest.fixture(scope="module") def session(reg): - - # append to netrc file and set permissions level - args = ("icepyx_devteam", "urs.earthdata.nasa.gov", os.getenv("NSIDC_LOGIN")) - netrc_file = os.path.join(os.path.expanduser("~"), ".netrc") - with open(netrc_file, "a+") as f: - f.write("machine {1} login {0} password {2}\n".format(*args)) - os.chmod(netrc_file, 0o600) - - reg.earthdata_login() - ed_obj = reg._session + ed_obj = reg.session yield ed_obj ed_obj.close() @@ -51,7 +42,7 @@ def test_get_custom_options_output(session): # NOTE: best this test can do at the moment is a successful download with no errors... def test_download_granules_with_subsetting(reg, session): path = "./downloads_subset" - reg._session = session + reg.session = session reg.order_granules() reg.download_granules(path)