|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | # mypy: ignore-errors
|
16 |
| - |
17 | 16 | import datetime
|
| 17 | +import pathlib |
18 | 18 | import unittest.mock
|
19 | 19 | import uuid
|
20 | 20 | from typing import Any
|
@@ -244,19 +244,32 @@ def test_get_job_from_broker_db() -> None:
|
244 | 244 |
|
245 | 245 |
|
246 | 246 | def test_update_results_href() -> None:
|
247 |
| - data_volume = "http://data_volume/" |
| 247 | + download_node = "http://download_node/" |
248 | 248 |
|
249 | 249 | local_path = "protocol://results/1234"
|
250 |
| - updated_href = utils.update_results_href(local_path, data_volume) |
251 |
| - exp_updated_href = "http://data_volume/results/1234" |
| 250 | + updated_href = utils.update_results_href(local_path, download_node) |
| 251 | + exp_updated_href = "http://download_node/results/1234" |
252 | 252 | assert updated_href == exp_updated_href
|
253 | 253 |
|
254 | 254 | local_path = "results/1234"
|
255 |
| - updated_href = utils.update_results_href(local_path, data_volume) |
256 |
| - exp_updated_href = "http://data_volume/results/1234" |
| 255 | + updated_href = utils.update_results_href(local_path, download_node) |
| 256 | + exp_updated_href = "http://download_node/results/1234" |
257 | 257 | assert updated_href == exp_updated_href
|
258 | 258 |
|
259 | 259 |
|
| 260 | +def test_update_results_href_from_config( |
| 261 | + monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path |
| 262 | +) -> None: |
| 263 | + config_path = tmp_path / "download-nodes.config" |
| 264 | + config_path.write_text("\n\nhttp://download_node/\n\n$DOWNLOAD_NODE\n\n") |
| 265 | + monkeypatch.setenv("DOWNLOAD_NODE", "http://download_node/") |
| 266 | + monkeypatch.setenv("DOWNLOAD_NODES_CONFIG", str(config_path)) |
| 267 | + |
| 268 | + local_path = "protocol://results/1234" |
| 269 | + updated_href = utils.update_results_href(local_path) |
| 270 | + assert updated_href == "http://download_node/results/1234" |
| 271 | + |
| 272 | + |
260 | 273 | def test_get_results_from_job() -> None:
|
261 | 274 | mock_session = unittest.mock.Mock(spec=sqlalchemy.orm.Session)
|
262 | 275 | job = cads_broker.SystemRequest(
|
|
0 commit comments