Skip to content

Commit 433c1e8

Browse files
committed
Add tests.
1 parent a246c29 commit 433c1e8

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

tests/tests_integration/test_configs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ def test_warning_on_startup(self, no_cfg_project):
4848
"Use make_config_file() to setup before continuing."
4949
)
5050

51-
def test_empty_project_name(self):
51+
def test_empty_project_name(self, tmp_path):
5252
"""
5353
Empty project names ("") are not allowed.
5454
"""
55+
os.chdir(tmp_path) # avoids messy backup folder creation
56+
5557
with pytest.raises(NeuroBlueprintError) as e:
5658
DataShuttle("")
5759

tests/tests_tui/test_tui_configs.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,44 @@ async def test_bad_configs_screen_input(self, empty_project_paths):
360360
)
361361
await pilot.pause()
362362

363+
# -------------------------------------------------------------------------
364+
# Test project name is number
365+
# -------------------------------------------------------------------------
366+
367+
@pytest.mark.asyncio
368+
async def test_project_name_is_number(self):
369+
"""
370+
Make a project that has a number name, and check the project screen
371+
can be loaded.
372+
"""
373+
app = TuiApp()
374+
async with app.run_test(size=self.tui_size()) as pilot:
375+
376+
# Set up a project with a numerical project name
377+
project_name = "123"
378+
379+
await self.scroll_to_click_pause(
380+
pilot, "#mainwindow_new_project_button"
381+
)
382+
383+
await self.fill_input(pilot, "#configs_name_input", project_name)
384+
await self.fill_input(pilot, "#configs_local_path_input", "a")
385+
await self.fill_input(pilot, "#configs_central_path_input", "b")
386+
await self.scroll_to_click_pause(
387+
pilot, "#configs_save_configs_button"
388+
)
389+
390+
# Go back to main menu and load the project screen
391+
await self.close_messagebox(pilot)
392+
393+
await self.scroll_to_click_pause(pilot, "#all_main_menu_buttons")
394+
395+
await self.check_and_click_onto_existing_project(
396+
pilot, project_name
397+
)
398+
399+
await pilot.pause()
400+
363401
# -------------------------------------------------------------------------
364402
# Helpers
365403
# -------------------------------------------------------------------------

tests/tests_tui/tui_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async def check_and_click_onto_existing_project(self, pilot, project_name):
166166
assert len(pilot.app.screen.project_names) == 1
167167
assert project_name in pilot.app.screen.project_names
168168

169-
await pilot.click(f"#{project_name}")
169+
await pilot.click(f"#safety_prefix_{project_name}")
170170
await pilot.pause()
171171

172172
assert isinstance(pilot.app.screen, ProjectManagerScreen)

0 commit comments

Comments
 (0)