Skip to content

Commit 4f83b06

Browse files
ishan372orpre-commit-ci[bot]JoeZiminski
authored
Default to "all" subjects or sessions for custom transfer if input left blank (#669)
* Fix #619: Handle blank subject/session inputs in TUI * TUI: clarify placeholder * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing tests for placeholders * Add test. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test manually, remove quotes from all * Fix tests. * Linting. * chore: retrigger CI * Revert erroneous test deletion. * Fix linting. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: JoeZiminski <joseph.j.ziminski@gmail.com>
1 parent c99dfb9 commit 4f83b06

3 files changed

Lines changed: 45 additions & 5 deletions

File tree

datashuttle/tui/tabs/transfer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ def compose(self) -> ComposeResult:
132132
ClickableInput(
133133
self.mainwindow,
134134
id="transfer_subject_input",
135-
placeholder="e.g. sub-001",
135+
placeholder="e.g. sub-001 (default: all)",
136136
),
137137
Label("Session(s)", id="transfer_session_label"),
138138
ClickableInput(
139139
self.mainwindow,
140140
id="transfer_session_input",
141-
placeholder="e.g. ses-001",
141+
placeholder="e.g. ses-001 (default: all)",
142142
),
143143
# These are almost identical to create tab
144144
Label("Datatype(s)", id="transfer_datatype_label"),
@@ -409,6 +409,12 @@ def transfer_data(self) -> Worker[InterfaceOutput]:
409409
"#transfer_subject_input", "#transfer_session_input"
410410
)
411411
)
412+
413+
if sub_names == [""]:
414+
sub_names = ["all"]
415+
if ses_names == [""]:
416+
ses_names = ["all"]
417+
412418
success, output = self.interface.transfer_custom_selection(
413419
selected_top_level_folder,
414420
sub_names,

tests/tests_tui/test_tui_transfer.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,41 @@ async def test_transfer_custom(
218218

219219
await pilot.pause()
220220

221+
@pytest.mark.asyncio()
222+
async def test_custom_transfer_default_sub_ses_all(
223+
self, mocker, setup_project_paths
224+
):
225+
"""
226+
This PR tests that for subject and session inputs on the custom
227+
transfer screen, passing no argument will call the transfer
228+
function with arguments "all".
229+
"""
230+
tmp_config_path, tmp_path, project_name = setup_project_paths.values()
231+
232+
app = TuiApp()
233+
async with app.run_test(size=self.tui_size()) as pilot:
234+
await self.check_and_click_onto_existing_project(
235+
pilot, project_name
236+
)
237+
await self.switch_tab(pilot, "transfer")
238+
239+
await self.scroll_to_click_pause(
240+
pilot, "#transfer_custom_radiobutton"
241+
)
242+
243+
spy_download_custom = mocker.spy(
244+
pilot.app.screen.interface.project, "download_custom"
245+
)
246+
247+
await self.run_transfer(pilot, "download")
248+
249+
_, kwargs_ = spy_download_custom.call_args_list[0]
250+
251+
assert kwargs_["sub_names"] == ["all"]
252+
assert kwargs_["ses_names"] == ["all"]
253+
254+
await pilot.pause()
255+
221256
async def switch_top_level_folder_select(
222257
self, pilot, id, top_level_folder
223258
):

tests/tests_tui/test_tui_widgets_and_defaults.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,6 @@ async def test_all_checkboxes(self, setup_project_paths):
10831083
pilot, f"#transfer_{datatype}_checkbox"
10841084
)
10851085
expected_transfer[datatype]["on"] = True
1086-
10871086
self.check_datatype_checkboxes(
10881087
pilot, "transfer", expected_transfer
10891088
)
@@ -1291,7 +1290,7 @@ async def test_all_transfer_widgets(self, setup_project_paths):
12911290
pilot.app.screen.query_one(
12921291
"#transfer_subject_input"
12931292
).placeholder
1294-
== "e.g. sub-001"
1293+
== "e.g. sub-001 (default: all)"
12951294
)
12961295

12971296
assert (
@@ -1304,7 +1303,7 @@ async def test_all_transfer_widgets(self, setup_project_paths):
13041303
pilot.app.screen.query_one(
13051304
"#transfer_session_input"
13061305
).placeholder
1307-
== "e.g. ses-001"
1306+
== "e.g. ses-001 (default: all)"
13081307
)
13091308

13101309
assert (

0 commit comments

Comments
 (0)