Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Commit

Permalink
Type hint stage bool for _client_get
Browse files Browse the repository at this point in the history
 - Update docs
  • Loading branch information
astrochun committed Feb 17, 2021
1 parent 1878f21 commit 552a631
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@


def test_figshare_get():
def _client_get(article_id0: Union[int, str] = '', stage=False):
def _client_get(article_id0: Union[int, str] = '', stage: bool = False):
return client.get(f'/api/{api_version}/figshare/'
f'{article_id0}?stage={stage}')

# Production
############
response = _client_get(article_id)
assert response.status_code == 200
assert isinstance(response.json(), dict)
assert response.json()['id'] == article_id

# Check for incorrect entry
# Check for incorrect entries with prod endpoint
response = _client_get(stage_article_id)
assert response.status_code == 404

Expand All @@ -34,12 +35,13 @@ def _client_get(article_id0: Union[int, str] = '', stage=False):
assert response.status_code == 404

# Stage
#######
response = _client_get(stage_article_id, stage=True)
assert response.status_code == 200
assert isinstance(response.json(), dict)
assert response.json()['id'] == stage_article_id

# Check for incorrect entry
# Check for incorrect entries with stage endpoint
response = _client_get(article_id, stage=True)
assert response.status_code == 404

Expand All @@ -52,17 +54,18 @@ def _client_get(article_id0: Union[int, str] = '', stage=False):


def test_metadata_get():
def _client_get(article_id0: Union[int, str] = '', stage=False):
def _client_get(article_id0: Union[int, str] = '', stage: bool = False):
return client.get(f'/api/{api_version}/metadata/'
f'{article_id0}?stage={stage}')

# Production
############
response = _client_get(article_id)
assert response.status_code == 200
assert isinstance(response.json(), dict)
assert response.json()['article_id'] == article_id

# Check for incorrect entry
# Check for incorrect entries with prod endpoint
response = _client_get(stage_article_id)
assert response.status_code == 404

Expand All @@ -74,12 +77,13 @@ def _client_get(article_id0: Union[int, str] = '', stage=False):
assert response.status_code == 404

# Stage
#######
response = _client_get(stage_article_id, stage=True)
assert response.status_code == 200
assert isinstance(response.json(), dict)
assert response.json()['article_id'] == stage_article_id

# Check for incorrect entry
# Check for incorrect entries with stage endpoint
response = _client_get(article_id, stage=True)
assert response.status_code == 404

Expand Down

0 comments on commit 552a631

Please sign in to comment.