@@ -89,12 +89,43 @@ def test_rsyncer_initialises(
8989 assert not rsyncer ._finalising
9090 assert not rsyncer ._finalised
9191
92- assert rsyncer .status == "ready"
92+
93+ @pytest .mark .parametrize (
94+ "test_params" ,
95+ (
96+ # Is stopping? | Is thread alive? | Expected status
97+ (False , False , "ready" ),
98+ (False , True , "running" ),
99+ (True , True , "stopping" ),
100+ (True , False , "finished" ),
101+ ),
102+ )
103+ def test_rsyncer_status (
104+ tmp_path : Path ,
105+ mock_server_url : MagicMock ,
106+ test_params : tuple [bool , bool , str ],
107+ ):
108+ # Unpack test params
109+ is_stopping , is_thread_alive , expected_status = test_params
110+
111+ # Mock the thread
112+ mock_thread = MagicMock ()
113+ mock_thread .is_alive .return_value = is_thread_alive
114+
115+ # Initialise the RSyncer and patch the attributes to be tested
116+ rsyncer = RSyncer (
117+ basepath_local = tmp_path / "local" ,
118+ basepath_remote = tmp_path / "remote" ,
119+ rsync_module = mock .ANY ,
120+ server_url = mock_server_url ,
121+ )
122+ rsyncer .thread = mock_thread
123+ rsyncer ._stopping = is_stopping
93124
94125 # Check that it's represented correctly
95126 assert (
96127 str (rsyncer )
97- == f"<RSyncer ({ rsyncer ._basepath } → { rsyncer ._remote } ) [{ rsyncer . status } ]"
128+ == f"<RSyncer ({ rsyncer ._basepath } → { rsyncer ._remote } ) [{ expected_status } ]"
98129 )
99130
100131
0 commit comments