Skip to content

Commit de9922a

Browse files
committed
Added integrated test for 'url_path_for' and its dependencies
1 parent 7f0ec44 commit de9922a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/util/test_api.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pytest
2+
3+
from murfey.util.api import url_path_for
4+
5+
url_path_test_matrix: tuple[tuple[str, str, dict[str, str | int], str], ...] = (
6+
# Router name | Function name | kwargs | Expected URL
7+
(
8+
"instrument_server.api.router",
9+
"health",
10+
{},
11+
"/health",
12+
),
13+
(
14+
"instrument_server.api.router",
15+
"stop_multigrid_watcher",
16+
{"session_id": 0, "label": "some_label"},
17+
"/sessions/0/multigrid_watcher/some_label",
18+
),
19+
(
20+
"api.hub.router",
21+
"get_instrument_image",
22+
{"instrument_name": "test"},
23+
"/instrument/test/image",
24+
),
25+
(
26+
"api.instrument.router",
27+
"check_if_session_is_active",
28+
{
29+
"instrument_name": "test",
30+
"session_id": 0,
31+
},
32+
"/instrument_server/instruments/test/sessions/0/active",
33+
),
34+
)
35+
36+
37+
@pytest.mark.parametrize("test_params", url_path_test_matrix)
38+
def test_url_path_for(test_params: tuple[str, str, dict[str, str | int], str]):
39+
# Unpack test params
40+
router_name, function_name, kwargs, expected_url_path = test_params
41+
assert (
42+
url_path_for(router_name=router_name, function_name=function_name, **kwargs)
43+
== expected_url_path
44+
)

0 commit comments

Comments
 (0)