diff --git a/datashuttle/tui/app.py b/datashuttle/tui/app.py index d374b4af3..411f9ef8c 100644 --- a/datashuttle/tui/app.py +++ b/datashuttle/tui/app.py @@ -166,7 +166,11 @@ def rename_file_or_folder(self, path_, new_name): path_.as_posix(), path_.parent / f"{new_name}{path_.suffix}", ) - self.query_one("#project_manager_screen").update_active_tab_tree() + assert isinstance( + self.screen, project_manager.ProjectManagerScreen + ) + self.screen.update_active_tab_tree() + except BaseException as e: self.show_modal_error_dialog( f"Could not rename the file or folder." diff --git a/datashuttle/tui/css/tui_tab.tcss b/datashuttle/tui/css/tui_tab.tcss index bfbfe3a96..34321a84c 100644 --- a/datashuttle/tui/css/tui_tab.tcss +++ b/datashuttle/tui/css/tui_tab.tcss @@ -32,6 +32,7 @@ TabScreen > TabbedContent { #create_folders_buttons_horizontal { height: 3; + margin: 0 0 1 0 } #template_settings_validation_on_checkbox.-on > .toggle--button{ @@ -52,9 +53,6 @@ TabScreen > TabbedContent { layout: horizontal; background: transparent; margin: 1 0 0 0; -} - -#transfer_radioset:focus { border: transparent; } diff --git a/pyproject.toml b/pyproject.toml index 997f6f406..9ca0f69e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = [ "fancylog>=0.4.2", "simplejson", "pyperclip", - "textual<=1.0.0", + "textual==3.4.0", "show-in-file-manager", "gitpython", "typeguard" diff --git a/tests/tests_tui/test_tui_configs.py b/tests/tests_tui/test_tui_configs.py index da853f8bc..00b30b781 100644 --- a/tests/tests_tui/test_tui_configs.py +++ b/tests/tests_tui/test_tui_configs.py @@ -397,7 +397,7 @@ async def check_configs_widgets_match_configs( assert ( configs_content.query_one( "#configs_connect_method_radioset" - ).pressed_button.label._text[0] + ).pressed_button.label._text == label ) diff --git a/tests/tests_tui/test_tui_datatypes.py b/tests/tests_tui/test_tui_datatypes.py index 508c2d06a..0e9ec8a64 100644 --- a/tests/tests_tui/test_tui_datatypes.py +++ b/tests/tests_tui/test_tui_datatypes.py @@ -50,7 +50,9 @@ async def test_select_displayed_datatypes_create( for datatype in narrow_datatype_names: assert ( - pilot.app.query_one(f"#create_{datatype}_checkbox").value + pilot.app.screen.query_one( + f"#create_{datatype}_checkbox" + ).value is False ) @@ -96,7 +98,9 @@ async def test_select_displayed_datatypes_create( for datatype in broad_datatype_names: # check all are shown and False again (because False on reset) assert ( - pilot.app.query_one(f"#create_{datatype}_checkbox").value + pilot.app.screen.query_one( + f"#create_{datatype}_checkbox" + ).value is False ) @@ -116,13 +120,15 @@ async def test_select_displayed_datatypes_create( for datatype in broad_datatype_names: # check all are shown and False again assert ( - pilot.app.query_one(f"#create_{datatype}_checkbox").value + pilot.app.screen.query_one( + f"#create_{datatype}_checkbox" + ).value is False ) # Confirm also that narrow datatypes are not shown. with pytest.raises(BaseException): - pilot.app.query_one( + pilot.app.screen.query_one( f"#create_{narrow_datatype_names[0]}_checkbox" ) @@ -165,7 +171,9 @@ async def test_select_displayed_datatypes_transfer( for datatype in narrow_datatype_names: assert ( - pilot.app.query_one(f"#transfer_{datatype}_checkbox").value + pilot.app.screen.query_one( + f"#transfer_{datatype}_checkbox" + ).value is False ) diff --git a/tests/tests_tui/test_tui_validate.py b/tests/tests_tui/test_tui_validate.py index 3c1ca330f..0972c9756 100644 --- a/tests/tests_tui/test_tui_validate.py +++ b/tests/tests_tui/test_tui_validate.py @@ -58,7 +58,9 @@ async def test_validate_on_project_manager_output( written_lines = [ ele.text - for ele in pilot.app.query_one("#validate_richlog").lines + for ele in pilot.app.screen.query_one( + "#validate_richlog" + ).lines ] assert len(written_lines) == 3 @@ -157,7 +159,7 @@ async def test_validate_on_project_manager_kwargs( "validate_path_container", ]: with pytest.raises(textual.css.query.InvalidQueryFormat): - pilot.app.query_one(id) + pilot.app.screen.query_one(id) @pytest.mark.asyncio async def test_validate_at_path_kwargs(self, setup_project_paths, mocker): @@ -198,4 +200,4 @@ async def test_validate_at_path_kwargs(self, setup_project_paths, mocker): # Check removed widgets, this should be removed because always local with pytest.raises(textual.css.query.InvalidQueryFormat): - pilot.app.query_one("validate_include_central_checkbox") + pilot.app.screen.query_one("validate_include_central_checkbox") diff --git a/tests/tests_tui/test_tui_widgets_and_defaults.py b/tests/tests_tui/test_tui_widgets_and_defaults.py index e0b330797..a07092962 100644 --- a/tests/tests_tui/test_tui_widgets_and_defaults.py +++ b/tests/tests_tui/test_tui_widgets_and_defaults.py @@ -110,7 +110,7 @@ async def test_new_project_configs(self, empty_project_paths): assert ( configs_content.query_one( "#configs_connect_method_radioset" - ).pressed_button.label._text[0] + ).pressed_button.label._text == "Local Filesystem" ) @@ -327,38 +327,36 @@ async def test_create_folders_widgets_display(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#create_behav_checkbox" - ).label._text[0] + ).label._text == "behav" ) assert ( pilot.app.screen.query_one( "#create_ephys_checkbox" - ).label._text[0] + ).label._text == "ephys" ) assert ( pilot.app.screen.query_one( "#create_funcimg_checkbox" - ).label._text[0] + ).label._text == "funcimg" ) assert ( - pilot.app.screen.query_one( - "#create_anat_checkbox" - ).label._text[0] + pilot.app.screen.query_one("#create_anat_checkbox").label._text == "anat" ) assert ( pilot.app.screen.query_one( "#create_folders_create_folders_button" - ).label._text[0] + ).label._text == "Create Folders" ) assert ( pilot.app.screen.query_one( "#create_folders_settings_button" - ).label._text[0] + ).label._text == "Settings" ) @@ -404,7 +402,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#create_folders_settings_bypass_validation_checkbox" - ).label._text[0] + ).label._text == "Bypass validation" ) assert ( @@ -417,7 +415,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#template_settings_validation_on_checkbox" - ).label._text[0] + ).label._text == "Template Validation" ) assert ( @@ -453,7 +451,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#template_settings_radioset" - ).pressed_button.label._text[0] + ).pressed_button.label._text == "Subject" ) assert ( @@ -1053,19 +1051,19 @@ async def test_all_transfer_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#transfer_all_radiobutton" - ).label._text[0] + ).label._text == "All" ) assert ( pilot.app.screen.query_one( "#transfer_toplevel_radiobutton" - ).label._text[0] + ).label._text == "Top Level" ) assert ( pilot.app.screen.query_one( "#transfer_custom_radiobutton" - ).label._text[0] + ).label._text == "Custom" ) @@ -1095,7 +1093,7 @@ async def test_all_transfer_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#transfer_transfer_button" - ).label._text[0] + ).label._text == "Transfer" ) @@ -1163,44 +1161,44 @@ async def test_all_transfer_widgets(self, setup_project_paths): assert ( pilot.app.screen.query_one( "#transfer_behav_checkbox" - ).label._text[0] + ).label._text == "behav" ) assert ( pilot.app.screen.query_one( "#transfer_ephys_checkbox" - ).label._text[0] + ).label._text == "ephys" ) assert ( pilot.app.screen.query_one( "#transfer_funcimg_checkbox" - ).label._text[0] + ).label._text == "funcimg" ) assert ( pilot.app.screen.query_one( "#transfer_anat_checkbox" - ).label._text[0] + ).label._text == "anat" ) assert ( pilot.app.screen.query_one( "#transfer_all_checkbox" - ).label._text[0] + ).label._text == "all" ) assert ( pilot.app.screen.query_one( "#transfer_all_datatype_checkbox" - ).label._text[0] + ).label._text == "all datatype" ) assert ( pilot.app.screen.query_one( "#transfer_all_non_datatype_checkbox" - ).label._text[0] + ).label._text == "all non datatype" )