diff options
Diffstat (limited to 'tests/test_ute.py')
-rw-r--r-- | tests/test_ute.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_ute.py b/tests/test_ute.py index 9e33b38..03d8e84 100644 --- a/tests/test_ute.py +++ b/tests/test_ute.py @@ -50,6 +50,18 @@ def test_make_request_no_authorization(ute_client, mocker: MockerFixture): assert response.json()["success"] is True +def test_make_request_expired_authorization(ute_client, mocker: MockerFixture): + """Test the _make_request method when the authorization code has expired.""" + mocked_unauthorized_response = mocker.Mock(status_code=requests.codes.unauthorized) + mocked_success_response = mocker.Mock(status_code=requests.codes.ok, json=lambda: {"success": True}) + mocker.patch("requests.get", side_effect=[mocked_unauthorized_response, mocked_success_response]) + mocker.patch.object(ute_client, "_login") + response = ute_client._make_request("GET", "http://example.com") + assert response.status_code == requests.codes.ok + assert response.json()["success"] is True + ute_client._login.assert_called_once() + + def test_make_request_all_retries_failed(ute_client, mocker: MockerFixture): """Test the _make_request method when all retries fail.""" mocked_response = mocker.Mock() |