Skip to content

Commit 57f5423

Browse files
authored
fix(tests): patch out live connectivity probe in 4 micro-tests (#292)
BaseServerClient.__init__ performs its own live connectivity probe (check_connection()) before a test ever gets a chance to install a mock. tests/micro-tests/test_delete_element_request_body.py already documents and works around this (patch check_connection to a no-op for the duration of client construction); these four files never picked up that pattern, so they silently depended on a real, reachable Egeria platform at localhost:9443 -- which happened to be true on a dev machine running a live server, masking the bug, but fails outright in CI with no such server: PyegeriaConnectionException: Client failed to connect to the Egeria platform using URL `https://localhost:9443/api/about`. Confirmed against the v6.1.0 release workflow run: https://github.com/odpi/egeria-python/actions/runs/32277343662 Files fixed: - tests/micro-tests/test_get_guid_request.py - tests/micro-tests/test_metadata_expert_count.py - tests/micro-tests/test_automated_curation_engine_action.py - tests/micro-tests/governance/test_governance_officer_governed_by_paths.py Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
1 parent 1f47f3c commit 57f5423

4 files changed

Lines changed: 36 additions & 10 deletions

File tree

‎tests/micro-tests/governance/test_governance_officer_governed_by_paths.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
from unittest.mock import patch
2+
13
import pytest
24

35
from pyegeria.omvs.governance_officer import GovernanceOfficer
46

57

68
@pytest.mark.asyncio
79
async def test_detach_governed_by_uses_definition_path_segment():
8-
client = GovernanceOfficer("view-server", "https://localhost:9443", "user", "pwd")
10+
# BaseServerClient.__init__ does its own live connectivity probe
11+
# (check_connection()) before any mock can be installed, so
12+
# check_connection is patched out for the duration of client
13+
# construction -- otherwise this file would silently depend on a
14+
# reachable Egeria platform despite living in tests/micro-tests/.
15+
with patch("pyegeria.core._base_server_client.BaseServerClient.check_connection", return_value=""):
16+
client = GovernanceOfficer("view-server", "https://localhost:9443", "user", "pwd")
917
captured = {}
1018

1119
async def _fake_delete(url, body):

‎tests/micro-tests/test_automated_curation_engine_action.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@
99
actual @PostMapping route: .../governance-engines/{governanceEngineName}/engine-actions/
1010
initiate), so the method was unusable before the fix.
1111
"""
12-
from unittest.mock import MagicMock
12+
from unittest.mock import MagicMock, patch
1313

1414
from pyegeria.omvs.automated_curation import AutomatedCuration
1515

1616

1717
def _client():
18-
return AutomatedCuration(view_server="vs", platform_url="https://localhost:9443",
19-
user_id="u", user_pwd="p")
18+
# BaseServerClient.__init__ does its own live connectivity probe
19+
# (check_connection()) before any mock can be installed, so
20+
# check_connection is patched out for the duration of client
21+
# construction -- otherwise this file would silently depend on a
22+
# reachable Egeria platform despite living in tests/micro-tests/.
23+
with patch("pyegeria.core._base_server_client.BaseServerClient.check_connection", return_value=""):
24+
return AutomatedCuration(view_server="vs", platform_url="https://localhost:9443",
25+
user_id="u", user_pwd="p")
2026

2127

2228
def _mock_request(capture, payload):

‎tests/micro-tests/test_get_guid_request.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
shape was never checked, so get_linked_projects always returned
1414
NO_ELEMENTS_FOUND even when the server's raw response body had real data.
1515
"""
16-
from unittest.mock import MagicMock
16+
from unittest.mock import MagicMock, patch
1717

1818
from pyegeria.omvs.project_manager import ProjectManager
1919

2020

2121
def _client():
22-
return ProjectManager(view_server="vs", platform_url="https://localhost:9443",
23-
user_id="u", user_pwd="p")
22+
# BaseServerClient.__init__ does its own live connectivity probe
23+
# (check_connection()) before any mock can be installed, so
24+
# check_connection is patched out for the duration of client
25+
# construction -- otherwise this file would silently depend on a
26+
# reachable Egeria platform despite living in tests/micro-tests/.
27+
with patch("pyegeria.core._base_server_client.BaseServerClient.check_connection", return_value=""):
28+
return ProjectManager(view_server="vs", platform_url="https://localhost:9443",
29+
user_id="u", user_pwd="p")
2430

2531

2632
def _mock_request(payload):

‎tests/micro-tests/test_metadata_expert_count.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
No live server: `_async_make_request` is mocked to return a CountResponse. Verifies
88
the endpoint URL, POST method, body slimming, asOfTime pass-through, and count parsing.
99
"""
10-
from unittest.mock import MagicMock
10+
from unittest.mock import MagicMock, patch
1111

1212
from pyegeria.omvs.metadata_expert import MetadataExpert
1313

1414

1515
def _client():
16-
return MetadataExpert(view_server="vs", platform_url="https://localhost:9443",
17-
user_id="u", user_pwd="p")
16+
# BaseServerClient.__init__ does its own live connectivity probe
17+
# (check_connection()) before any mock can be installed, so
18+
# check_connection is patched out for the duration of client
19+
# construction -- otherwise this file would silently depend on a
20+
# reachable Egeria platform despite living in tests/micro-tests/.
21+
with patch("pyegeria.core._base_server_client.BaseServerClient.check_connection", return_value=""):
22+
return MetadataExpert(view_server="vs", platform_url="https://localhost:9443",
23+
user_id="u", user_pwd="p")
1824

1925

2026
def _mock_request(capture, count_payload):

0 commit comments

Comments
 (0)