diff --git a/doccano_client/repositories/base.py b/doccano_client/repositories/base.py index 7f3760a..20a9ea9 100644 --- a/doccano_client/repositories/base.py +++ b/doccano_client/repositories/base.py @@ -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) diff --git a/tests/unit/repositories/test_base.py b/tests/unit/repositories/test_base.py index 200f213..6ee426d 100644 --- a/tests/unit/repositories/test_base.py +++ b/tests/unit/repositories/test_base.py @@ -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