diff --git a/swh/web/client/client.py b/swh/web/client/client.py index 540c13034fc7a2d05861b98e7542b9f8286d83c1..f59c2ff1fffd9cfdc962dccd3297cd33126c53de 100644 --- a/swh/web/client/client.py +++ b/swh/web/client/client.py @@ -213,7 +213,6 @@ class _RateLimitInfo: return r def replacing(self, other): - if other.reset_date != self.reset_date: # the one with a later reset date is likely more up to date. return other.reset_date < self.reset_date @@ -918,12 +917,8 @@ class WebAPIClient: return r.text def cooking_request( - self, - bundle_type: str, - swhid: SWHIDish, - email: Optional[str] = None, - **req_args - ) -> Dict[str,Any]: + self, bundle_type: str, swhid: SWHIDish, email: Optional[str] = None, **req_args + ) -> Dict[str, Any]: """Request a cooking of a bundle Args: @@ -946,16 +941,18 @@ class WebAPIClient: """ q = f"vault/{bundle_type}/{swhid}/" - r = self._call(q, http_method="post", json={"email":email},**req_args,) + r = self._call( + q, + http_method="post", + json={"email": email}, + **req_args, + ) r.raise_for_status() return r.json() def cooking_check( - self, - bundle_type:str, - swhid: SWHIDish, - **req_args - ) -> Dict[str,Any]: + self, bundle_type: str, swhid: SWHIDish, **req_args + ) -> Dict[str, Any]: """Check the status of a cooking task Args: @@ -977,15 +974,16 @@ class WebAPIClient: """ q = f"vault/{bundle_type}/{swhid}/" - r = self._call(q, http_method="get",**req_args,) + r = self._call( + q, + http_method="get", + **req_args, + ) r.raise_for_status() return r.json() def cooking_fetch( - self, - bundle_type:str, - swhid: SWHIDish, - **req_args + self, bundle_type: str, swhid: SWHIDish, **req_args ) -> requests.models.Response: """Fetch the archive of a cooking task @@ -1003,6 +1001,11 @@ class WebAPIClient: """ q = f"vault/{bundle_type}/{swhid}/raw" - r = self._call(q, http_method="get",stream=True,**req_args,) + r = self._call( + q, + http_method="get", + stream=True, + **req_args, + ) r.raise_for_status() return r diff --git a/swh/web/client/tests/test_web_api_client.py b/swh/web/client/tests/test_web_api_client.py index c23b9ac681d03ab73300333738ed3d8331b2e99d..6c229525bef221ab6596e507eef6021233ba333f 100644 --- a/swh/web/client/tests/test_web_api_client.py +++ b/swh/web/client/tests/test_web_api_client.py @@ -333,8 +333,9 @@ def test_iter(web_api_client, web_api_mock, swhid, swhid_type, typify): def test_cooking_request(web_api_client, web_api_mock): dir_swhid = "swh:1:dir:977fc4b98c0e85816348cebd3b12026407c368b6" obj = web_api_client.cooking_request("flat", dir_swhid) - assert obj["fetch_url"] == ("https://archive.softwareheritage.org/api/1/vault/flat/" - + dir_swhid + "/raw/") + assert obj["fetch_url"] == ( + "https://archive.softwareheritage.org/api/1/vault/flat/" + dir_swhid + "/raw/" + ) assert obj["status"] == "pending" assert obj["swhid"] == dir_swhid assert obj["id"] == 415999462 @@ -344,8 +345,9 @@ def test_cooking_request(web_api_client, web_api_mock): def test_cooking_check(web_api_client, web_api_mock): dir_swhid = "swh:1:dir:977fc4b98c0e85816348cebd3b12026407c368b6" obj = web_api_client.cooking_check("flat", dir_swhid) - assert obj["fetch_url"] == ("https://archive.softwareheritage.org/api/1/vault/flat/" - + dir_swhid + "/raw/") + assert obj["fetch_url"] == ( + "https://archive.softwareheritage.org/api/1/vault/flat/" + dir_swhid + "/raw/" + ) assert obj["status"] == "pending" assert obj["swhid"] == dir_swhid assert obj["id"] == 415999462