Skip to content

Commit ef792d2

Browse files
committed
wrap str as list, add 4) to bad input test
1 parent 42553c1 commit ef792d2

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

tests/test_packsmanager.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_tmp_file_structure(input, expected, example_cases):
112112
# 8) copy all examples from list of packs
113113
# 9) copy all examples from all packs
114114
( # 1) copy one example, (ambiguous)
115-
"ex1",
115+
["ex1"],
116116
[
117117
Path("packA/ex1/path1/script1.py"),
118118
Path("packB/ex1/path2/script2.py"),
@@ -134,7 +134,7 @@ def test_tmp_file_structure(input, expected, example_cases):
134134
],
135135
),
136136
( # 4) copy one example (unambiguous)
137-
"ex2",
137+
["ex2"],
138138
[
139139
Path("packA/ex2/script3.py"),
140140
],
@@ -154,7 +154,7 @@ def test_tmp_file_structure(input, expected, example_cases):
154154
],
155155
),
156156
( # 7) copy all examples from a pack
157-
"packA",
157+
["packA"],
158158
[
159159
Path("packA/ex1/path1/script1.py"),
160160
Path("packA/ex2/script3.py"),
@@ -171,7 +171,7 @@ def test_tmp_file_structure(input, expected, example_cases):
171171
],
172172
),
173173
( # 9) copy all examples from all packs
174-
"all",
174+
["all"],
175175
[
176176
Path("packA/ex1/path1/script1.py"),
177177
Path("packA/ex2/script3.py"),
@@ -190,7 +190,7 @@ def test_copy_examples(input, expected_paths, example_cases):
190190
examples_dir = example_cases / "case5"
191191
pm = PacksManager(root_path=examples_dir)
192192
target_dir = example_cases / "user_target"
193-
actual = pm.copy_examples(user_input=input, target_dir=target_dir)
193+
actual = pm.copy_examples(examples_to_copy=input, target_dir=target_dir)
194194
expected = []
195195
for path in expected_paths:
196196
root_path = target_dir / path
@@ -212,48 +212,54 @@ def test_copy_examples_location(input, expected_path, example_cases):
212212
examples_dir = example_cases / "case5"
213213
os.chdir(example_cases / "cwd")
214214
pm = PacksManager(root_path=examples_dir)
215-
paths = pm.copy_examples(user_input="packA", target_dir=input)
215+
paths = pm.copy_examples(examples_to_copy=["packA"], target_dir=input)
216216
actual = paths[0]
217217
expected = example_cases / expected_path
218218
assert actual == expected
219219

220220

221221
# Test bad inputs to copy_examples on case3
222222
# These include:
223-
# 1) input not found (example or pack)
224-
# 2) mixed good and bad inputs
223+
# 1) Input not found (example or pack)
224+
# 2) Mixed good and bad inputs
225225
# 3) Path to directory already exists
226+
# 4) No input provided
226227
@pytest.mark.parametrize(
227228
"bad_inputs,expected,path",
228229
[
229-
(
230-
"bad_example",
230+
( # input not found (example or pack)
231+
["bad_example"],
231232
ValueError,
232233
None,
233-
), # input not found (example or pack)
234-
(
234+
),
235+
( # mixed good ex and bad inputs
235236
["ex1", "bad_example"],
236237
ValueError,
237238
None,
238-
), # mixed good ex and bad inputs
239-
(
239+
),
240+
( # mixed good pack and bad inputs
240241
["packA", "bad_example"],
241242
ValueError,
242243
None,
243-
), # mixed good pack and bad inputs
244-
(
245-
"ex1",
244+
),
245+
( # path to dir already exists
246+
["ex1"],
246247
FileExistsError,
247248
Path("docs/examples/"),
248-
), # path to dir already exists
249+
),
250+
( # No input provided
251+
[],
252+
ValueError,
253+
None,
254+
),
249255
],
250256
)
251257
def test_copy_examples_bad(bad_inputs, expected, path, example_cases):
252258
examples_dir = example_cases / "case3"
253259
pm = PacksManager(root_path=examples_dir)
254260
with pytest.raises(expected):
255261
pm.copy_examples(
256-
user_input=bad_inputs,
262+
examples_to_copy=bad_inputs,
257263
target_dir=examples_dir / path if path is not None else None,
258264
)
259265

@@ -281,6 +287,6 @@ def test_copy_examples_bad_target(bad_inputs, expected, example_cases):
281287
pm = PacksManager(root_path=examples_dir)
282288
with pytest.raises(expected):
283289
pm.copy_examples(
284-
user_input="packA",
290+
examples_to_copy="packA",
285291
target_dir=bad_inputs,
286292
)

0 commit comments

Comments
 (0)