|
6 | 6 | import pytest |
7 | 7 | from pytest_mock import MockerFixture |
8 | 8 |
|
9 | | -from murfey.client.contexts.fib import FIBContext, _get_source, _number_from_name |
| 9 | +from murfey.client.contexts.fib import ( |
| 10 | + FIBContext, |
| 11 | + _file_transferred_to, |
| 12 | + _get_source, |
| 13 | + _number_from_name, |
| 14 | +) |
10 | 15 |
|
11 | 16 | # ------------------------------------------------------------------------------------- |
12 | 17 | # FIBContext test utilty functions and fixtures |
@@ -237,7 +242,37 @@ def test_get_source( |
237 | 242 | assert _get_source(file, mock_environment) == visit_dir |
238 | 243 |
|
239 | 244 |
|
240 | | -def test_file_transferred_to(): |
| 245 | +def test_file_transferred_to( |
| 246 | + mocker: MockerFixture, |
| 247 | + tmp_path: Path, |
| 248 | + visit_dir: Path, |
| 249 | + fib_maps_images: list[Path], |
| 250 | + fib_maps_metadata_file: Path, |
| 251 | +): |
| 252 | + # Mock the machine config and environment |
| 253 | + mock_get_machine_config = mocker.patch( |
| 254 | + "murfey.client.contexts.fib.get_machine_config_client" |
| 255 | + ) |
| 256 | + mock_get_machine_config.return_value = { |
| 257 | + "rsync_basepath": tmp_path / "fib" / "data", |
| 258 | + } |
| 259 | + mock_environment = MagicMock() |
| 260 | + mock_environment.default_destinations = {visit_dir: "current_year"} |
| 261 | + mock_environment.visit = "visit" |
| 262 | + |
| 263 | + # Iterate across the FIB files to compare against |
| 264 | + destination_dir = tmp_path / "fib" / "data" / "current_year" / "visit" |
| 265 | + for file in [fib_maps_metadata_file, *fib_maps_images]: |
| 266 | + # Work out what the expected destination will be |
| 267 | + assert _file_transferred_to( |
| 268 | + environment=mock_environment, |
| 269 | + source=visit_dir, |
| 270 | + file_path=file, |
| 271 | + token="", |
| 272 | + ) == destination_dir / file.relative_to(visit_dir) |
| 273 | + |
| 274 | + |
| 275 | +def test_parse_electron_snapshot_metadata(): |
241 | 276 | pass |
242 | 277 |
|
243 | 278 |
|
|
0 commit comments