22from unittest .mock import MagicMock
33
44import pytest
5- import pytest_asyncio
65
76from recoverpy import RecoverpyApp
87from tests .conftest import TEST_BLOCK_SIZE
2322)
2423
2524
26- @pytest .mark .asyncio (scope = "class" )
27- @pytest .mark .incremental
28- class TestFullWorkflow :
29- @pytest_asyncio .fixture (scope = "class" )
30- def session_patch (self , session_mocker ):
31- session_mocker .patch (
32- "recoverpy.lib.env_check._is_user_root" ,
33- MagicMock (return_value = True ),
34- )
35- session_mocker .patch (
36- "recoverpy.lib.env_check._are_system_dependencies_installed" ,
37- MagicMock (return_value = True ),
38- )
39- session_mocker .patch (
40- "recoverpy.lib.env_check._is_linux" ,
41- MagicMock (return_value = True ),
42- )
43-
44- @pytest_asyncio .fixture (scope = "class" )
45- async def pilot (self , session_patch ):
46- async with RecoverpyApp ().run_test () as p :
47- yield p
48-
49- async def test_init_app (self , pilot ):
25+ @pytest .mark .asyncio
26+ async def test_full_workflow (session_mocker , tmp_path : Path ):
27+ # Apply patches
28+ session_mocker .patch (
29+ "recoverpy.lib.env_check._is_user_root" ,
30+ MagicMock (return_value = True ),
31+ )
32+ session_mocker .patch (
33+ "recoverpy.lib.env_check._are_system_dependencies_installed" ,
34+ MagicMock (return_value = True ),
35+ )
36+ session_mocker .patch (
37+ "recoverpy.lib.env_check._is_linux" ,
38+ MagicMock (return_value = True ),
39+ )
40+
41+ # Launch the application
42+ async with RecoverpyApp ().run_test () as pilot :
43+ # Test initialization of the app
5044 assert pilot .app is not None
5145 for screen in pilot .app .screens :
5246 assert pilot .app .is_screen_installed (pilot .app .screens [screen ])
@@ -59,16 +53,15 @@ async def test_init_app(self, pilot):
5953 )
6054 assert pilot .app .screen ._start_search_button .disabled is True
6155
62- async def test_partition_list_default_state ( self , pilot ):
56+ # Test partition list default state
6357 filter_checkbox = pilot .app .query ("Checkbox" ).only_one ()
6458 assert filter_checkbox is not None
6559 assert filter_checkbox .value is True
6660
6761 items = list (pilot .app .query ("ListItem" ).results ())
6862 assert len (items ) == VISIBLE_PARTITION_COUNT
6963
70- async def test_partition_list_unfiltered (self , pilot ):
71- filter_checkbox = pilot .app .query ("Checkbox" ).only_one ()
64+ # Test partition list unfiltered
7265 filter_checkbox .toggle ()
7366 await pilot .pause ()
7467
@@ -80,8 +73,7 @@ async def test_partition_list_unfiltered(self, pilot):
8073 len (list (pilot .app .query ("ListItem" ).results ())),
8174 )
8275
83- async def test_partition_list_filtered (self , pilot ):
84- filter_checkbox = pilot .app .query ("Checkbox" ).only_one ()
76+ # Test partition list filtered
8577 filter_checkbox .toggle ()
8678 await pilot .pause ()
8779
@@ -93,7 +85,7 @@ async def test_partition_list_filtered(self, pilot):
9385 len (list (pilot .app .query ("ListItem" ).results ())),
9486 )
9587
96- async def test_input_search_params ( self , pilot ):
88+ # Test input search parameters
9789 await pilot .click ("#search-input" )
9890 await pilot .pause ()
9991
@@ -109,7 +101,7 @@ async def test_input_search_params(self, pilot):
109101 assert pilot .app .screen ._partition_list .highlighted_child .id == TEST_PARTITION
110102 assert pilot .app .screen ._start_search_button .disabled is False
111103
112- async def test_start_search ( self , pilot ):
104+ # Test start search
113105 await pilot .click ("#start-search-button" )
114106 await pilot .pause ()
115107
@@ -121,7 +113,7 @@ async def test_start_search(self, pilot):
121113 == TEST_FULL_PARTITION
122114 )
123115
124- async def test_search_results ( self , pilot ):
116+ # Test search results
125117 await assert_with_timeout (
126118 lambda : int (pilot .app .screen .search_engine .search_progress .progress_percent )
127119 == 100 ,
@@ -147,7 +139,7 @@ async def test_search_results(self, pilot):
147139 len (list (pilot .app .query ("ListItem" ).results ())),
148140 )
149141
150- async def test_select_search_results ( self , pilot ):
142+ # Test select search results
151143 list_items = list (pilot .app .query ("ListItem" ).results ())
152144
153145 for item in list_items :
@@ -157,7 +149,7 @@ async def test_select_search_results(self, pilot):
157149 assert item .highlighted is True
158150 assert pilot .app .screen ._get_selected_grep_result ().list_item == item
159151
160- async def test_open_result ( self , pilot ):
152+ # Test open result
161153 select_item = pilot .app .screen ._grep_result_list .highlighted_child
162154 assert select_item is not None
163155 select_grep_result = pilot .app .screen ._get_selected_grep_result ()
@@ -172,7 +164,7 @@ async def test_open_result(self, pilot):
172164 assert pilot .app .screen ._block_size == TEST_BLOCK_SIZE
173165 assert pilot .app .screen ._inode == select_grep_result .inode
174166
175- async def test_result_content ( self , pilot ):
167+ # Test result content
176168 await pilot .pause ()
177169
178170 assert (
@@ -184,7 +176,7 @@ async def test_result_content(self, pilot):
184176 pilot .app .screen ._inode
185177 ) == get_block_content_text (pilot .app .screen ._block_content )
186178
187- async def test_select_first_result ( self , pilot ):
179+ # Test select first result
188180 await pilot .click ("#add-block-button" )
189181 await pilot .pause ()
190182
@@ -200,7 +192,7 @@ async def test_select_first_result(self, pilot):
200192 assert len (pilot .app .screen ._saver ._results ) == 1
201193 add_expected_save_result (pilot )
202194
203- async def test_select_next_result ( self , pilot ):
195+ # Test select next result
204196 current_inode = pilot .app .screen ._inode
205197 await pilot .click ("#next-button" )
206198 await pilot .pause ()
@@ -225,10 +217,12 @@ async def test_select_next_result(self, pilot):
225217 await assert_current_result_is_selected_for_save (pilot )
226218
227219 await pilot .click ("#add-block-button" )
220+ await pilot .pause ()
221+
228222 assert len (pilot .app .screen ._saver ._results ) == 2
229223 add_expected_save_result (pilot )
230224
231- async def test_select_previous_result ( self , pilot ):
225+ # Test select previous result
232226 previous_button = pilot .app .query ("#previous-button" ).only_one ()
233227 current_inode = pilot .app .screen ._inode
234228 await pilot .click ("#previous-button" )
@@ -271,13 +265,13 @@ async def test_select_previous_result(self, pilot):
271265 assert len (pilot .app .screen ._saver ._results ) == 3
272266 add_expected_save_result (pilot )
273267
274- async def test_start_save_process ( self , pilot ):
268+ # Test start save process
275269 await pilot .click ("#save-button" )
276270 await pilot .pause ()
277271
278272 assert pilot .app .screen .name == "save"
279273
280- async def test_edit_save_path ( self , pilot , tmp_path : Path ):
274+ # Test edit save path
281275 await pilot .click ("#edit-save-path-button" )
282276 await pilot .pause ()
283277
@@ -298,7 +292,7 @@ async def test_edit_save_path(self, pilot, tmp_path: Path):
298292 assert pilot .app .screen .name == "save"
299293 assert pilot .app .screen ._saver .save_path == tmp_path
300294
301- async def test_save_results ( self , pilot ):
295+ # Test save results
302296 await pilot .click ("#save-button" )
303297 await pilot .pause ()
304298
@@ -309,7 +303,7 @@ async def test_save_results(self, pilot):
309303
310304 assert pilot .app .screen .name == "result"
311305
312- def check_saved_result ( self , tmp_path : Path ):
306+ # Check saved result
313307 dir_files = list (tmp_path .iterdir ())
314308 assert len (dir_files ) == 1
315309 assert dir_files [0 ].name .startswith ("recoverpy-save-" )
0 commit comments