Skip to content

Commit d05ed6f

Browse files
committed
Improve test coverage
1 parent 471f841 commit d05ed6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_tools/test_tools_welcome.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,28 @@ def testToolWelcome_Main(qtbot, monkeypatch, nwGUI, fncPath):
6969
assert selected[0] == SAMPLE_NAME
7070
assert selected[1] == SAMPLE_KEY
7171
welcome.tabOpen._selectFirstItem()
72+
73+
# A folder must be selected
74+
with monkeypatch.context() as mp:
75+
mp.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: None)
76+
welcome.tabOpen._processOpenProjectRequest(SAMPLE_KEY)
77+
78+
assert SHARED.lastAlert[0] == "You must select a location for the example project."
79+
80+
# Successful
7281
with monkeypatch.context() as mp:
7382
mp.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: fncPath)
7483
welcome.tabOpen._processOpenProjectRequest(SAMPLE_KEY)
84+
7585
assert (fncPath / SAMPLE_NAME).is_dir()
7686

87+
# But can't create a duplicate
88+
with monkeypatch.context() as mp:
89+
mp.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: fncPath)
90+
welcome.tabOpen._processOpenProjectRequest(SAMPLE_KEY)
91+
92+
assert SHARED.lastAlert[0] == "The target folder already exists. Please choose another folder."
93+
7794
# qtbot.stop()
7895
welcome.close()
7996

0 commit comments

Comments
 (0)