stdlib, tests: Fixed bugs and tests

- Fixed bugs rekated to retrying on request faliure.
- Updated the pyunit tests.

Change-Id: Ia484690267bf27018488324f3408f7e47c59bef3
This commit is contained in:
Harshil Patel
2023-10-10 15:54:20 -07:00
parent 51c881d0f1
commit bbc301f2f0
2 changed files with 26 additions and 49 deletions

View File

@@ -30,7 +30,7 @@ import json
import time
import itertools
from .abstract_client import AbstractClient
from urllib.error import HTTPError
from m5.util import warn
@@ -77,7 +77,7 @@ class AtlasClient(AbstractClient):
def get_token(self):
return self._atlas_http_json_req(
self.url,
self.authUrl,
data_json={"key": self.apiKey},
headers={"Content-Type": "application/json"},
purpose_of_request="Get Access Token with API key",
@@ -122,7 +122,7 @@ class AtlasClient(AbstractClient):
try:
response = request.urlopen(req)
break
except Exception as e:
except HTTPError as e:
if attempt >= max_failed_attempts:
raise AtlasClientHttpJsonRequestError(
client=self,
@@ -167,7 +167,10 @@ class AtlasClient(AbstractClient):
}
resources = self._atlas_http_json_req(
url, data=data, headers=headers, purpose_of_request="Get Resources"
url,
data_json=data,
headers=headers,
purpose_of_request="Get Resources",
)["documents"]
# I do this as a lazy post-processing step because I can't figure out