Skip to content

Commit

Permalink
remove .netrc creation and update existing tests to new auth method
Browse files Browse the repository at this point in the history
  • Loading branch information
rwegener2 committed Aug 14, 2023
1 parent 7e8bf0f commit e06765a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 4 additions & 0 deletions icepyx/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions icepyx/tests/test_behind_NSIDC_API_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

Expand Down

0 comments on commit e06765a

Please sign in to comment.