Skip to content

Commit 44bd759

Browse files
authored
Update textual to 3.4.0 (#524)
* Update textual and some minor tcss. * Change _text[0] to _text in tests. * Update pilot.app.query_one call. * Rework update tab tree call in tests.
1 parent bf81924 commit 44bd759

7 files changed

Lines changed: 47 additions & 37 deletions

File tree

datashuttle/tui/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ def rename_file_or_folder(self, path_, new_name):
166166
path_.as_posix(),
167167
path_.parent / f"{new_name}{path_.suffix}",
168168
)
169-
self.query_one("#project_manager_screen").update_active_tab_tree()
169+
assert isinstance(
170+
self.screen, project_manager.ProjectManagerScreen
171+
)
172+
self.screen.update_active_tab_tree()
173+
170174
except BaseException as e:
171175
self.show_modal_error_dialog(
172176
f"Could not rename the file or folder."

datashuttle/tui/css/tui_tab.tcss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TabScreen > TabbedContent {
3232

3333
#create_folders_buttons_horizontal {
3434
height: 3;
35+
margin: 0 0 1 0
3536
}
3637

3738
#template_settings_validation_on_checkbox.-on > .toggle--button{
@@ -52,9 +53,6 @@ TabScreen > TabbedContent {
5253
layout: horizontal;
5354
background: transparent;
5455
margin: 1 0 0 0;
55-
}
56-
57-
#transfer_radioset:focus {
5856
border: transparent;
5957
}
6058

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies = [
1919
"fancylog>=0.4.2",
2020
"simplejson",
2121
"pyperclip",
22-
"textual<=1.0.0",
22+
"textual==3.4.0",
2323
"show-in-file-manager",
2424
"gitpython",
2525
"typeguard"

tests/tests_tui/test_tui_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ async def check_configs_widgets_match_configs(
397397
assert (
398398
configs_content.query_one(
399399
"#configs_connect_method_radioset"
400-
).pressed_button.label._text[0]
400+
).pressed_button.label._text
401401
== label
402402
)
403403

tests/tests_tui/test_tui_datatypes.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ async def test_select_displayed_datatypes_create(
5050

5151
for datatype in narrow_datatype_names:
5252
assert (
53-
pilot.app.query_one(f"#create_{datatype}_checkbox").value
53+
pilot.app.screen.query_one(
54+
f"#create_{datatype}_checkbox"
55+
).value
5456
is False
5557
)
5658

@@ -96,7 +98,9 @@ async def test_select_displayed_datatypes_create(
9698
for datatype in broad_datatype_names:
9799
# check all are shown and False again (because False on reset)
98100
assert (
99-
pilot.app.query_one(f"#create_{datatype}_checkbox").value
101+
pilot.app.screen.query_one(
102+
f"#create_{datatype}_checkbox"
103+
).value
100104
is False
101105
)
102106

@@ -116,13 +120,15 @@ async def test_select_displayed_datatypes_create(
116120
for datatype in broad_datatype_names:
117121
# check all are shown and False again
118122
assert (
119-
pilot.app.query_one(f"#create_{datatype}_checkbox").value
123+
pilot.app.screen.query_one(
124+
f"#create_{datatype}_checkbox"
125+
).value
120126
is False
121127
)
122128

123129
# Confirm also that narrow datatypes are not shown.
124130
with pytest.raises(BaseException):
125-
pilot.app.query_one(
131+
pilot.app.screen.query_one(
126132
f"#create_{narrow_datatype_names[0]}_checkbox"
127133
)
128134

@@ -165,7 +171,9 @@ async def test_select_displayed_datatypes_transfer(
165171

166172
for datatype in narrow_datatype_names:
167173
assert (
168-
pilot.app.query_one(f"#transfer_{datatype}_checkbox").value
174+
pilot.app.screen.query_one(
175+
f"#transfer_{datatype}_checkbox"
176+
).value
169177
is False
170178
)
171179

tests/tests_tui/test_tui_validate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ async def test_validate_on_project_manager_output(
5858

5959
written_lines = [
6060
ele.text
61-
for ele in pilot.app.query_one("#validate_richlog").lines
61+
for ele in pilot.app.screen.query_one(
62+
"#validate_richlog"
63+
).lines
6264
]
6365

6466
assert len(written_lines) == 3
@@ -157,7 +159,7 @@ async def test_validate_on_project_manager_kwargs(
157159
"validate_path_container",
158160
]:
159161
with pytest.raises(textual.css.query.InvalidQueryFormat):
160-
pilot.app.query_one(id)
162+
pilot.app.screen.query_one(id)
161163

162164
@pytest.mark.asyncio
163165
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):
198200

199201
# Check removed widgets, this should be removed because always local
200202
with pytest.raises(textual.css.query.InvalidQueryFormat):
201-
pilot.app.query_one("validate_include_central_checkbox")
203+
pilot.app.screen.query_one("validate_include_central_checkbox")

tests/tests_tui/test_tui_widgets_and_defaults.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def test_new_project_configs(self, empty_project_paths):
110110
assert (
111111
configs_content.query_one(
112112
"#configs_connect_method_radioset"
113-
).pressed_button.label._text[0]
113+
).pressed_button.label._text
114114
== "Local Filesystem"
115115
)
116116

@@ -327,38 +327,36 @@ async def test_create_folders_widgets_display(self, setup_project_paths):
327327
assert (
328328
pilot.app.screen.query_one(
329329
"#create_behav_checkbox"
330-
).label._text[0]
330+
).label._text
331331
== "behav"
332332
)
333333
assert (
334334
pilot.app.screen.query_one(
335335
"#create_ephys_checkbox"
336-
).label._text[0]
336+
).label._text
337337
== "ephys"
338338
)
339339
assert (
340340
pilot.app.screen.query_one(
341341
"#create_funcimg_checkbox"
342-
).label._text[0]
342+
).label._text
343343
== "funcimg"
344344
)
345345
assert (
346-
pilot.app.screen.query_one(
347-
"#create_anat_checkbox"
348-
).label._text[0]
346+
pilot.app.screen.query_one("#create_anat_checkbox").label._text
349347
== "anat"
350348
)
351349

352350
assert (
353351
pilot.app.screen.query_one(
354352
"#create_folders_create_folders_button"
355-
).label._text[0]
353+
).label._text
356354
== "Create Folders"
357355
)
358356
assert (
359357
pilot.app.screen.query_one(
360358
"#create_folders_settings_button"
361-
).label._text[0]
359+
).label._text
362360
== "Settings"
363361
)
364362

@@ -404,7 +402,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths):
404402
assert (
405403
pilot.app.screen.query_one(
406404
"#create_folders_settings_bypass_validation_checkbox"
407-
).label._text[0]
405+
).label._text
408406
== "Bypass validation"
409407
)
410408
assert (
@@ -417,7 +415,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths):
417415
assert (
418416
pilot.app.screen.query_one(
419417
"#template_settings_validation_on_checkbox"
420-
).label._text[0]
418+
).label._text
421419
== "Template Validation"
422420
)
423421
assert (
@@ -453,7 +451,7 @@ async def test_create_folder_settings_widgets(self, setup_project_paths):
453451
assert (
454452
pilot.app.screen.query_one(
455453
"#template_settings_radioset"
456-
).pressed_button.label._text[0]
454+
).pressed_button.label._text
457455
== "Subject"
458456
)
459457
assert (
@@ -1053,19 +1051,19 @@ async def test_all_transfer_widgets(self, setup_project_paths):
10531051
assert (
10541052
pilot.app.screen.query_one(
10551053
"#transfer_all_radiobutton"
1056-
).label._text[0]
1054+
).label._text
10571055
== "All"
10581056
)
10591057
assert (
10601058
pilot.app.screen.query_one(
10611059
"#transfer_toplevel_radiobutton"
1062-
).label._text[0]
1060+
).label._text
10631061
== "Top Level"
10641062
)
10651063
assert (
10661064
pilot.app.screen.query_one(
10671065
"#transfer_custom_radiobutton"
1068-
).label._text[0]
1066+
).label._text
10691067
== "Custom"
10701068
)
10711069

@@ -1095,7 +1093,7 @@ async def test_all_transfer_widgets(self, setup_project_paths):
10951093
assert (
10961094
pilot.app.screen.query_one(
10971095
"#transfer_transfer_button"
1098-
).label._text[0]
1096+
).label._text
10991097
== "Transfer"
11001098
)
11011099

@@ -1163,44 +1161,44 @@ async def test_all_transfer_widgets(self, setup_project_paths):
11631161
assert (
11641162
pilot.app.screen.query_one(
11651163
"#transfer_behav_checkbox"
1166-
).label._text[0]
1164+
).label._text
11671165
== "behav"
11681166
)
11691167
assert (
11701168
pilot.app.screen.query_one(
11711169
"#transfer_ephys_checkbox"
1172-
).label._text[0]
1170+
).label._text
11731171
== "ephys"
11741172
)
11751173
assert (
11761174
pilot.app.screen.query_one(
11771175
"#transfer_funcimg_checkbox"
1178-
).label._text[0]
1176+
).label._text
11791177
== "funcimg"
11801178
)
11811179
assert (
11821180
pilot.app.screen.query_one(
11831181
"#transfer_anat_checkbox"
1184-
).label._text[0]
1182+
).label._text
11851183
== "anat"
11861184
)
11871185

11881186
assert (
11891187
pilot.app.screen.query_one(
11901188
"#transfer_all_checkbox"
1191-
).label._text[0]
1189+
).label._text
11921190
== "all"
11931191
)
11941192
assert (
11951193
pilot.app.screen.query_one(
11961194
"#transfer_all_datatype_checkbox"
1197-
).label._text[0]
1195+
).label._text
11981196
== "all datatype"
11991197
)
12001198
assert (
12011199
pilot.app.screen.query_one(
12021200
"#transfer_all_non_datatype_checkbox"
1203-
).label._text[0]
1201+
).label._text
12041202
== "all non datatype"
12051203
)
12061204

0 commit comments

Comments
 (0)