Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
creisle committed Jan 18, 2024
1 parent c7273df commit 310df1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions doccano_client/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def get_next_url(base_url: str, initial_url: str, response_data: dict) -> Option
The adjusted url to get the next page or None when no next page is available
"""
if response_data.get('next') is None:
if response_data.get("next") is None:
return None
next_url = response_data['next']
next_url = response_data["next"]
try:
resource = initial_url[len(base_url) :]
_, next_suffix = next_url.split(resource)
Expand Down
46 changes: 23 additions & 23 deletions tests/unit/repositories/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,50 @@


@pytest.mark.parametrize(
'base_url,initial_request_url,response_url,next_url',
"base_url,initial_request_url,response_url,next_url",
[
(
'https://hostname.ca',
'https://hostname.ca/projects',
'http://hostname.ca/projects?limit=5&offset=5',
'https://hostname.ca/projects?limit=5&offset=5',
"https://hostname.ca",
"https://hostname.ca/projects",
"http://hostname.ca/projects?limit=5&offset=5",
"https://hostname.ca/projects?limit=5&offset=5",
),
(
'https://hostname.ca',
'https://hostname.ca/projects',
'http://localhost:3000/projects?limit=5&offset=5',
'https://hostname.ca/projects?limit=5&offset=5',
"https://hostname.ca",
"https://hostname.ca/projects",
"http://localhost:3000/projects?limit=5&offset=5",
"https://hostname.ca/projects?limit=5&offset=5",
),
(
'https://hostname.ca',
'https://hostname.ca/projects',
'http://localhost:3000/projects?limit=5&offset=5',
'https://hostname.ca/projects?limit=5&offset=5',
"https://hostname.ca",
"https://hostname.ca/projects",
"http://localhost:3000/projects?limit=5&offset=5",
"https://hostname.ca/projects?limit=5&offset=5",
),
(
'https://hostname.ca',
'https://hostname.ca/projects',
'https://hostname.ca/projects?limit=5&offset=5',
'https://hostname.ca/projects?limit=5&offset=5',
"https://hostname.ca",
"https://hostname.ca/projects",
"https://hostname.ca/projects?limit=5&offset=5",
"https://hostname.ca/projects?limit=5&offset=5",
),
],
)
def test_get_next_url(base_url, initial_request_url, response_url, next_url):
url = get_next_url(base_url, initial_request_url, {'next': response_url})
url = get_next_url(base_url, initial_request_url, {"next": response_url})
assert url == next_url


@pytest.mark.parametrize(
'base_url,initial_request_url,response_url',
"base_url,initial_request_url,response_url",
[
(
'https://hostname.ca',
'https://hostname.ca/projects',
'http://hostname.ca/things?limit=5&offset=5',
"https://hostname.ca",
"https://hostname.ca/projects",
"http://hostname.ca/things?limit=5&offset=5",
),
],
)
def test_get_next_url_error(base_url, initial_request_url, response_url):
# should return the unmodified url when in doubt
url = get_next_url(base_url, initial_request_url, {'next': response_url})
url = get_next_url(base_url, initial_request_url, {"next": response_url})
assert url == response_url

0 comments on commit 310df1c

Please sign in to comment.