|
8 | 8 | from fastapi.testclient import TestClient |
9 | 9 | from pytest_mock import MockerFixture |
10 | 10 |
|
11 | | -from murfey.instrument_server.api import GainReference, _get_murfey_url |
| 11 | +from murfey.instrument_server.api import _get_murfey_url |
12 | 12 | from murfey.instrument_server.api import router as client_router |
13 | | -from murfey.instrument_server.api import upload_gain_reference, validate_session_token |
| 13 | +from murfey.instrument_server.api import validate_session_token |
14 | 14 | from murfey.util import posix_path |
15 | 15 | from murfey.util.api import url_path_for |
16 | 16 |
|
@@ -105,7 +105,7 @@ def test_upload_gain_reference( |
105 | 105 | ): |
106 | 106 | # Unpack test parameters and define other ones |
107 | 107 | (rsync_url_setting,) = test_params |
108 | | - server_url = "http://0.0.0.0:8000" |
| 108 | + server_url = "https://murfey.server.test" |
109 | 109 | instrument_name = "murfey" |
110 | 110 | session_id = 1 |
111 | 111 |
|
@@ -142,13 +142,18 @@ def test_upload_gain_reference( |
142 | 142 | "visit_path": visit_path, |
143 | 143 | "gain_destination_dir": gain_dest_dir, |
144 | 144 | } |
145 | | - result = upload_gain_reference( |
| 145 | + |
| 146 | + # Set up instrument server test client |
| 147 | + client_server = set_up_test_client(session_id=session_id) |
| 148 | + |
| 149 | + # Poke the endpoint with the expected data |
| 150 | + url_path = url_path_for( |
| 151 | + "api.router", |
| 152 | + "upload_gain_reference", |
146 | 153 | instrument_name=instrument_name, |
147 | 154 | session_id=session_id, |
148 | | - gain_reference=GainReference( |
149 | | - **payload, |
150 | | - ), |
151 | 155 | ) |
| 156 | + response = client_server.post(url_path, json=payload) |
152 | 157 |
|
153 | 158 | # Check that the machine config request was called |
154 | 159 | machine_config_url = f"{server_url}{url_path_for('session_control.router', 'machine_info_by_instrument', instrument_name=instrument_name)}" |
@@ -176,4 +181,4 @@ def test_upload_gain_reference( |
176 | 181 | ) |
177 | 182 |
|
178 | 183 | # Check that the function ran through to completion successfully |
179 | | - assert result == {"success": True} |
| 184 | + assert response.json() == {"success": True} |
0 commit comments