Skip to content

Commit a3cfb85

Browse files
committed
Fixed which function/module layer to mock
1 parent ed38844 commit a3cfb85

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tests/instrument_server/test_api.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434

3535

3636
@mark.parametrize("test_params", test_upload_gain_reference_params_matrix)
37-
@patch("murfey.instrument_server.api.subprocess.run")
37+
@patch("murfey.instrument_server.api.subprocess")
3838
@patch("murfey.instrument_server.api.urlparse", wraps=urlparse)
3939
@patch("murfey.instrument_server.api._get_murfey_url")
40-
@patch("murfey.instrument_server.api.requests.get")
40+
@patch("murfey.instrument_server.api.requests")
4141
def test_upload_gain_reference(
42-
mock_get,
43-
mock_server_url,
42+
mock_request,
43+
mock_get_server_url,
4444
spy_parse,
45-
mock_run,
45+
mock_subprocess,
4646
test_params: tuple[Optional[str], str, str],
4747
):
4848

@@ -57,9 +57,12 @@ def test_upload_gain_reference(
5757
mock_machine_config["rsync_url"] = rsync_url
5858

5959
# Assign expected values to the mock objects
60-
mock_get.return_value = Mock(status_code=200, json=lambda: mock_machine_config)
61-
mock_server_url.return_value = server_url
62-
mock_run.return_value = Mock(returncode=0)
60+
mock_request.get.return_value = Mock(
61+
status_code=200,
62+
json=lambda: mock_machine_config,
63+
)
64+
mock_get_server_url.return_value = server_url
65+
mock_subprocess.run.return_value = Mock(returncode=0)
6366

6467
# Construct payload and submit post request
6568
payload = {
@@ -72,7 +75,7 @@ def test_upload_gain_reference(
7275
)
7376

7477
# Check that the machine config request was called
75-
mock_get.assert_called_once()
78+
mock_request.get.assert_called_once()
7679

7780
# If no rsync_url key is provided, or rsync_url key is empty,
7881
# This should default to the Murfey URL
@@ -82,7 +85,7 @@ def test_upload_gain_reference(
8285
assert spy_parse.return_value == urlparse(rsync_url)
8386

8487
# Check that the subprocess was run
85-
mock_run.assert_called_once()
88+
mock_subprocess.run.assert_called_once()
8689

8790
# Check that the endpoint function ran through to completion successfully
8891
assert response.status_code == 200

0 commit comments

Comments
 (0)