|
6 | 6 |
|
7 | 7 | import requests_mock |
8 | 8 |
|
| 9 | +from podman.domain.config import PodmanConfig, ServiceConnection |
9 | 10 | from podman import PodmanClient, tests |
10 | 11 | from podman.api.path_utils import get_runtime_dir, get_xdg_config_home |
11 | 12 |
|
@@ -108,6 +109,23 @@ def test_connect_default(self): |
108 | 109 | expected = Path(get_xdg_config_home()) / "containers" / "containers.conf" |
109 | 110 | PodmanClientTestCase.opener.assert_called_with(expected, encoding="utf-8") |
110 | 111 |
|
| 112 | + def test_connect_with_connection_file(self): |
| 113 | + mock_config = MagicMock(spec=PodmanConfig) |
| 114 | + mock_service = MagicMock(spec=ServiceConnection) |
| 115 | + mock_service.url.geturl.return_value = ( |
| 116 | + "http+ssh://[email protected]:58468/run/user/501/podman/podman.sock" |
| 117 | + ) |
| 118 | + mock_service.identity = "/Users/test/.local/share/containers/podman/machine/machine" |
| 119 | + mock_service.is_machine = True |
| 120 | + mock_config.active_service = mock_service |
| 121 | + |
| 122 | + with mock.patch('podman.client.PodmanConfig', return_value=mock_config): |
| 123 | + # Mock pathlib.Path.exists to return True for the identity file |
| 124 | + with mock.patch('pathlib.Path.exists', return_value=True): |
| 125 | + with PodmanClient() as client: |
| 126 | + expected = "http+ssh://[email protected]:58468/run/user/501/podman/podman.sock" |
| 127 | + self.assertEqual(client.api.base_url.geturl(), expected) |
| 128 | + |
111 | 129 |
|
112 | 130 | if __name__ == '__main__': |
113 | 131 | unittest.main() |
0 commit comments