Skip to content

Commit 7d08e2e

Browse files
committed
Parametrised the '_get_murfey_url' test
1 parent a4a274b commit 7d08e2e

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/instrument_server/test_api.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,40 @@
1212
)
1313
from murfey.util import posix_path
1414

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+
1524

25+
@mark.parametrize("test_params", test_get_murfey_url_params_matrix)
1626
def test_get_murfey_url(
27+
test_params: tuple[str],
1728
mock_client_configuration, # From conftest.py
1829
):
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+
1937
# Mock the module-wide config variable with the fixture value
2038
# The fixture is only loaded within the test function, so this patch
2139
# has to happen inside the function instead of as a decorator
2240
with patch("murfey.instrument_server.api.config", mock_client_configuration):
2341
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
2549

2650

2751
test_upload_gain_reference_params_matrix = (

0 commit comments

Comments
 (0)