forked from nsidc/earthaccess
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated get_s3fs_session (nsidc#768)
Co-authored-by: Chuck Daniels <[email protected]>
- Loading branch information
1 parent
3a8f6ac
commit 0945db5
Showing
8 changed files
with
130 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import contextlib | ||
import warnings | ||
from unittest import mock | ||
|
||
import earthaccess | ||
import pytest | ||
import responses | ||
from earthaccess.api import get_s3fs_session | ||
from earthaccess.store import Store | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
@responses.activate | ||
@mock.patch("getpass.getpass") | ||
@mock.patch("builtins.input") | ||
def auth(user_input, user_password): | ||
user_input.return_value = "user" | ||
user_password.return_value = "password" | ||
json_response = [ | ||
{"access_token": "EDL-token-1", "expiration_date": "12/15/2021"}, | ||
{"access_token": "EDL-token-2", "expiration_date": "12/16/2021"}, | ||
] | ||
responses.add( | ||
responses.GET, | ||
"https://urs.earthdata.nasa.gov/api/users/tokens", | ||
json=json_response, | ||
status=200, | ||
) | ||
responses.add( | ||
responses.GET, | ||
"https://urs.earthdata.nasa.gov/profile", | ||
json={"email_address": "[email protected]"}, | ||
status=200, | ||
) | ||
|
||
earthaccess.login(strategy="interactive") | ||
|
||
return earthaccess.__auth__ | ||
|
||
|
||
def test_deprecation_warning_for_api(): | ||
with warnings.catch_warnings(record=True) as w: | ||
# Cause all warnings to always be triggered. | ||
warnings.simplefilter("always") | ||
# Trigger a warning. | ||
with contextlib.suppress(AttributeError): | ||
get_s3fs_session() | ||
# Verify some things | ||
assert issubclass(w[0].category, DeprecationWarning) | ||
assert "Use get_s3_filesystem instead" in str(w[0].message) | ||
|
||
|
||
def test_deprecation_warning_for_store(auth): | ||
store = Store(auth) | ||
with warnings.catch_warnings(record=True) as w: | ||
# Cause all warnings to always be triggered. | ||
warnings.simplefilter("always") | ||
# Trigger a warning. | ||
with contextlib.suppress(ValueError): | ||
store.get_s3fs_session() | ||
# Verify some things | ||
assert issubclass(w[0].category, DeprecationWarning) | ||
assert "Use get_s3_filesystem instead" in str(w[0].message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters