From eabdf1e3b0ca3840d7b43872d5cc1900f8bfe534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Fri, 12 Jul 2024 13:48:33 +0200 Subject: [PATCH] Fix coverage --- httpx_oauth/clients/linkedin.py | 2 +- tests/test_clients_openid.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/httpx_oauth/clients/linkedin.py b/httpx_oauth/clients/linkedin.py index 6c9ac8c..3b93a02 100644 --- a/httpx_oauth/clients/linkedin.py +++ b/httpx_oauth/clients/linkedin.py @@ -72,7 +72,7 @@ async def refresh_token(self, refresh_token: str) -> OAuth2Token: access_token = await client.refresh_token("REFRESH_TOKEN") ``` """ - return await super().refresh_token(refresh_token) + return await super().refresh_token(refresh_token) # pragma: no cover async def get_id_email(self, token: str) -> Tuple[str, Optional[str]]: async with self.get_httpx_client() as client: diff --git a/tests/test_clients_openid.py b/tests/test_clients_openid.py index e699ab8..d98e052 100644 --- a/tests/test_clients_openid.py +++ b/tests/test_clients_openid.py @@ -2,7 +2,7 @@ import pytest import respx -from httpx import Response +from httpx import HTTPError, Response from httpx_oauth.clients.openid import OpenID, OpenIDConfigurationError from httpx_oauth.exceptions import GetIdEmailError @@ -65,6 +65,19 @@ def test_openid_configuration_error(): ) +@respx.mock +def test_openid_configuration_http_error(): + respx.get( + re.compile("https://example.fief.dev/.well-known/openid-configuration") + ).mock(side_effect=HTTPError("ERROR")) + with pytest.raises(OpenIDConfigurationError): + OpenID( + "CLIENT_ID", + "CLIENT_SECRET", + "https://example.fief.dev/.well-known/openid-configuration", + ) + + @respx.mock def test_openid(client: OpenID): assert client.authorize_endpoint == "https://example.fief.dev/authorize"