|
12 | 12 | ) |
13 | 13 | from murfey.util import posix_path |
14 | 14 |
|
| 15 | +test_get_murfey_url_params_matrix = ( |
| 16 | + # Server URL to use |
| 17 | + ("default",), |
| 18 | + ("0.0.0.0:8000",), |
| 19 | + ("murfey_server",), |
| 20 | + ("http://murfey_server:8000",), |
| 21 | + ("http://murfey_server:8080/api",), |
| 22 | +) |
| 23 | + |
15 | 24 |
|
| 25 | +@mark.parametrize("test_params", test_get_murfey_url_params_matrix) |
16 | 26 | def test_get_murfey_url( |
| 27 | + test_params: tuple[str], |
17 | 28 | mock_client_configuration, # From conftest.py |
18 | 29 | ): |
| 30 | + # Unpack test_params |
| 31 | + (server_url_to_test,) = test_params |
| 32 | + |
| 33 | + # Replace the server URL from the fixture with other ones for testing |
| 34 | + if server_url_to_test != "default": |
| 35 | + mock_client_configuration["Murfey"]["server"] = server_url_to_test |
| 36 | + |
19 | 37 | # Mock the module-wide config variable with the fixture value |
20 | 38 | # The fixture is only loaded within the test function, so this patch |
21 | 39 | # has to happen inside the function instead of as a decorator |
22 | 40 | with patch("murfey.instrument_server.api.config", mock_client_configuration): |
23 | 41 | known_server = _get_murfey_url() |
24 | | - assert known_server == mock_client_configuration["Murfey"].get("server") |
| 42 | + parsed_server = urlparse(known_server) |
| 43 | + parsed_original = urlparse( |
| 44 | + str(mock_client_configuration["Murfey"].get("server")) |
| 45 | + ) |
| 46 | + assert parsed_server.scheme in ("http", "https") |
| 47 | + assert parsed_server.netloc == parsed_original.netloc |
| 48 | + assert parsed_server.path == parsed_original.path |
25 | 49 |
|
26 | 50 |
|
27 | 51 | test_upload_gain_reference_params_matrix = ( |
|
0 commit comments