Skip to content

Commit

Permalink
Added unitary test for Unauthorized token error.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAlcolea committed Dec 19, 2024
1 parent a8a17c9 commit 16b63d3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tests/connectors/aibuilder/test_aibuilder_mlmodel_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ def test_fetch_happy_path_unaware_datetime():
assert resource.resource.is_accessible_for_free


def test_unautorized_token_error():
error = {"error": {"message": "Unauthorized token."}}
err_msg = f"Error while fetching {catalog_list_url} from AIBuilder: (401) Unauthorized token."
fetched_resources = []
with responses.RequestsMock() as mocked_requests:
mocked_requests.add(responses.GET, catalog_list_url, json=error, status=401)
fetched_resources = list(connector.fetch(mocked_datetime_from, mocked_datetime_to))

assert len(fetched_resources) == 1
last_modified, resource = fetched_resources[0]
assert last_modified is None
assert type(resource) == RecordError
assert resource.identifier is None
assert type(resource.error) == HTTPError
assert str(resource.error) == err_msg
assert connector.is_concluded


def test_catalog_list_http_error():
error = {"error": {"message": "HTTP Error."}}
err_msg = f"Error while fetching {catalog_list_url} from AIBuilder: (500) Internal Server Error"
Expand Down

0 comments on commit 16b63d3

Please sign in to comment.