Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert unapproved user check #287

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.0.1]

### Removed
* Removed the unapproved user warning implemented in [v6.2.0](https://github.com/ASFHyP3/hyp3-sdk/releases/tag/v6.2.0) (see <https://github.com/ASFHyP3/hyp3-sdk/pull/276>). This feature had unintended consequences which broke some processing pipelines that rely on the HyP3 SDK (see <https://github.com/ASFHyP3/hyp3-sdk/issues/285> for more details).

## [7.0.0]

### Removed
Expand Down
14 changes: 0 additions & 14 deletions src/hyp3_sdk/hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ def __init__(self, api_url: str = PROD_API, username: Optional[str] = None, pass

self.session = hyp3_sdk.util.get_authenticated_session(username, password)
self.session.headers.update({'User-Agent': f'{hyp3_sdk.__name__}/{hyp3_sdk.__version__}'})
self._check_application_status()

def _check_application_status(self) -> None:
help_url = 'https://hyp3-docs.asf.alaska.edu/using/requesting_access'
info = self.my_info()
if info['application_status'] == 'NOT_STARTED':
warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.'
f' Please visit {help_url} to submit your application.')
if info['application_status'] == 'PENDING':
warnings.warn(f'User {info["user_id"]}\'s request for access is pending review. For more information, '
f'visit {help_url}')
if info['application_status'] == 'REJECTED':
warnings.warn(f'{info["user_id"]}\'s request for access has been rejected. For more information, '
f'visit {help_url}')

def find_jobs(self,
start: Optional[datetime] = None,
Expand Down
8 changes: 2 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@

@pytest.fixture(autouse=True)
def get_mock_hyp3():
def mock_my_info(self):
return {'application_status': 'APPROVED'}

def mock_get_authenticated_session(username, password):
return requests.Session()

def default_hyp3():
with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info):
with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session):
return HyP3()
with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session):
return HyP3()
return default_hyp3


Expand Down
37 changes: 0 additions & 37 deletions tests/test_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,43 +417,6 @@ def test_check_credits(get_mock_hyp3):
assert math.isclose(api.check_credits(), 25.)


@responses.activate
def test_check_application_status_approved(get_mock_hyp3):
with warnings.catch_warnings(record=True) as w:
_ = get_mock_hyp3()
assert len(w) == 0


@responses.activate
def test_check_application_status_errors(get_mock_hyp3):
application_status = 'NOT_STARTED'
with warnings.catch_warnings(record=True) as w:
with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser',
'application_status': application_status}):
with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()):
_ = HyP3()
assert len(w) == 1
assert 'not yet applied for a monthly credit allotment' in str(w[0].message)

application_status = 'PENDING'
with warnings.catch_warnings(record=True) as w:
with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser',
'application_status': application_status}):
with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()):
_ = HyP3()
assert len(w) == 1
assert 'request for access is pending review' in str(w[0].message)

application_status = 'REJECTED'
with warnings.catch_warnings(record=True) as w:
with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser',
'application_status': application_status}):
with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()):
_ = HyP3()
assert len(w) == 1
assert 'request for access has been rejected' in str(w[0].message)


@responses.activate
def test_costs(get_mock_hyp3):
api_response = {'foo': 5}
Expand Down
Loading