From 85876ebf9806ab8ca3a0a7326a79bc874fa7219d Mon Sep 17 00:00:00 2001 From: mwdd146980 Date: Thu, 23 Apr 2026 18:04:26 +0200 Subject: [PATCH 1/2] Fix gitlab conftest: json.loads for version response, remove dead /-/health branch --- gitlab/tests/conftest.py | 6 ++---- gitlab/tests/test_unit.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gitlab/tests/conftest.py b/gitlab/tests/conftest.py index b0d47e010b803..b7d24e38eadae 100644 --- a/gitlab/tests/conftest.py +++ b/gitlab/tests/conftest.py @@ -148,15 +148,13 @@ def mocked_requests_get(*args, **kwargs): iter_lines=lambda **kwargs: text_data.split("\n"), headers={'Content-Type': "text/plain"}, ) - elif url == "http://{}:{}/api/v4/version".format(HOST, GITLAB_LOCAL_PORT) or url == "http://{}:{}/-/health".format( - HOST, GITLAB_LOCAL_PORT - ): + elif url == "http://{}:{}/api/v4/version".format(HOST, GITLAB_LOCAL_PORT): f_name = os.path.join(os.path.dirname(__file__), 'fixtures', 'version.json') with open(f_name, 'r') as f: text_data = f.read() response = mock.MagicMock() response.status_code = 200 - response.json.return_value = text_data + response.json.return_value = json.loads(text_data) return response pytest.fail("url `{}` not registered".format(args[0])) diff --git a/gitlab/tests/test_unit.py b/gitlab/tests/test_unit.py index b0b6bd8f12cab..50c614b7a4e5d 100644 --- a/gitlab/tests/test_unit.py +++ b/gitlab/tests/test_unit.py @@ -12,7 +12,9 @@ CUSTOM_TAGS, GITALY_METRICS, GITLAB_GITALY_PROMETHEUS_ENDPOINT, + GITLAB_LOCAL_PORT, GITLAB_TAGS, + HOST, V1_METRICS, V2_METRICS, assert_check, @@ -173,3 +175,11 @@ def test_parse_readiness_service_checks( ) assert len(aggregator.service_check_names) == 13 + + +def test_version_mock_returns_parsed_dict(mock_data): + import requests + + session = requests.Session() + response = session.get("http://{}:{}/api/v4/version".format(HOST, GITLAB_LOCAL_PORT)) + assert response.json() == {"version": "1.2.3"} From 8f4832a904d1b8a82c89e6774310dc06edc3821a Mon Sep 17 00:00:00 2001 From: mwdd146980 Date: Thu, 23 Apr 2026 18:18:57 +0200 Subject: [PATCH 2/2] Drop test_version_mock_returns_parsed_dict: fix self-evident, test would need updates at httpx migration --- gitlab/tests/test_unit.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gitlab/tests/test_unit.py b/gitlab/tests/test_unit.py index 50c614b7a4e5d..b0b6bd8f12cab 100644 --- a/gitlab/tests/test_unit.py +++ b/gitlab/tests/test_unit.py @@ -12,9 +12,7 @@ CUSTOM_TAGS, GITALY_METRICS, GITLAB_GITALY_PROMETHEUS_ENDPOINT, - GITLAB_LOCAL_PORT, GITLAB_TAGS, - HOST, V1_METRICS, V2_METRICS, assert_check, @@ -175,11 +173,3 @@ def test_parse_readiness_service_checks( ) assert len(aggregator.service_check_names) == 13 - - -def test_version_mock_returns_parsed_dict(mock_data): - import requests - - session = requests.Session() - response = session.get("http://{}:{}/api/v4/version".format(HOST, GITLAB_LOCAL_PORT)) - assert response.json() == {"version": "1.2.3"}