44import pytest
55from pytest_mock import MockerFixture
66
7- from murfey .server .api .file_io_instrument import SuggestedPathParameters , suggest_path
7+ from murfey .server .api .file_io_instrument import (
8+ Dest ,
9+ SuggestedPathParameters ,
10+ make_rsyncer_destination ,
11+ suggest_path ,
12+ )
813
914
1015@pytest .mark .parametrize (
@@ -27,6 +32,8 @@ def test_suggest_path(
2732):
2833 # Unpack test params
2934 touch , extra_dir , has_raw = test_params
35+
36+ # Set other parameters
3037 instrument_name = "test"
3138 year = "2026"
3239 visit_name = "visit"
@@ -83,5 +90,64 @@ def test_suggest_path(
8390 assert (visit_dir / dir_name / extra_dir ).exists ()
8491
8592
86- def test_make_rsyncer_destination ():
87- pass
93+ @pytest .mark .parametrize (
94+ "dir_name" ,
95+ (
96+ # General
97+ "images" ,
98+ "screenshots" ,
99+ # SPA/Tomo-specific
100+ "raw" ,
101+ "raw2" ,
102+ "raw3" ,
103+ "atlas" ,
104+ # FIB-specific
105+ "autotem" ,
106+ "maps" ,
107+ "meteor" ,
108+ "extras" ,
109+ ),
110+ )
111+ def test_make_rsyncer_destination (
112+ mocker : MockerFixture ,
113+ dir_name : str ,
114+ tmp_path : Path ,
115+ ):
116+ # Set other parameters
117+ instrument_name = "test"
118+ year = "2026"
119+ visit_name = "visit"
120+ session_id = 1
121+
122+ rsync_basepath = tmp_path / "data"
123+ visit_dir = rsync_basepath / year / visit_name
124+ destination = visit_dir / dir_name
125+
126+ dest = Dest (destination = destination .relative_to (rsync_basepath ))
127+
128+ # Mock the database call
129+ mock_session = MagicMock ()
130+ mock_session .instrument_name = instrument_name
131+ mock_session .visit = visit_name
132+ mock_db = MagicMock ()
133+ mock_db .exec .return_value .one .return_value = mock_session
134+
135+ # Mock 'get_machine_config'
136+ mock_machine_config = MagicMock ()
137+ mock_machine_config .rsync_basepath = rsync_basepath
138+ mock_machine_config .mkdir_chmod = 0o775
139+ mocker .patch (
140+ "murfey.server.api.file_io_instrument.get_machine_config" ,
141+ return_value = {
142+ instrument_name : mock_machine_config ,
143+ },
144+ )
145+
146+ # Run the function and check expected outputs
147+ result = make_rsyncer_destination (
148+ session_id = session_id ,
149+ destination = dest ,
150+ db = mock_db ,
151+ )
152+ assert result == dest
153+ assert destination .exists ()
0 commit comments