Skip to content

Commit 790cac8

Browse files
committed
Added unit test for '_file_transferred_to' helper function
1 parent 9697027 commit 790cac8

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

tests/client/contexts/test_fib.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import pytest
77
from pytest_mock import MockerFixture
88

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+
)
1015

1116
# -------------------------------------------------------------------------------------
1217
# FIBContext test utilty functions and fixtures
@@ -237,7 +242,37 @@ def test_get_source(
237242
assert _get_source(file, mock_environment) == visit_dir
238243

239244

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():
241276
pass
242277

243278

0 commit comments

Comments
 (0)