From 729564d948571fe1b5dbd49761407109afd50103 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Fri, 21 Aug 2026 10:57:02 +0200 Subject: [PATCH] Fix some errors that prevented tests being skipped when the KG is unavailable --- test/test_client.py | 4 ++++ test/utils.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test_client.py b/test/test_client.py index c107a45d..a8c3166f 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -243,6 +243,10 @@ def offline_kg_client(mocker): must be patched per-test.""" from fairgraph.client import KGClient + # Building the kg-core client fetches the IAM token endpoint from the KG, which + # fails if the KG is unreachable (e.g. during maintenance). + mocker.patch("kg_core.__communication.TokenHandler.define_endpoint") + client = KGClient(token="fake-token", allow_interactive=False) # Skip the feature-detection fetch that the `migrated` property triggers. client._migrated = True diff --git a/test/utils.py b/test/utils.py index c8c83f08..04552191 100644 --- a/test/utils.py +++ b/test/utils.py @@ -3,7 +3,7 @@ from uuid import uuid4 from typing import Optional -from requests.exceptions import SSLError +from requests.exceptions import RequestException, SSLError from fairgraph.client import KGClient from fairgraph.errors import AuthenticationError, AuthorizationError @@ -20,6 +20,9 @@ pass except SSLError: no_kg_err_msg = "No KG connection - SSL certificate may have expired" +except RequestException: + # e.g. the KG is down for maintenance. + no_kg_err_msg = f"No KG connection - could not reach {kg_host}" else: try: user_info = client.user_info()