Skip to content

Commit d1038b7

Browse files
committed
UCs for copy_examples tests
1 parent c2e8076 commit d1038b7

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ def example_cases(tmp_path_factory):
8787

8888

8989
@pytest.fixture(scope="session")
90-
def copy_target_dir(tmp_path_factory):
90+
def target_dir(tmp_path_factory):
9191
"""Create a temporary directory to serve as the target for copying
9292
examples."""
93-
target_dir = tmp_path_factory.mktemp("copy_target")
94-
yield target_dir
93+
target_directory = tmp_path_factory.mktemp("copy_target")
94+
yield target_directory
9595

9696

9797
@pytest.fixture(scope="session", autouse=True)

tests/test_cli.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
11
import os
22
from pathlib import Path
3+
from shutil import copytree
34

45
import pytest
56

67
from diffpy.cmi import cli
78
from diffpy.cmi.packsmanager import PacksManager
89

910

11+
@pytest.mark.parametrize(
12+
"input,to_cwd,expected",
13+
[
14+
# PARAMS:
15+
# input: list - list of example(s) and/or pack(s) to copy
16+
# to_cwd: bool - whether to copy to cwd (default) or a target dir
17+
# expected: list - path of copied example(s) and/or pack(s)
18+
# 1a) user wants to copy one example to cwd
19+
# 1b) user wants to copy one example to a target dir
20+
(),
21+
# 2a) user wants to copy multiple examples to cwd
22+
# 2b) user wants to copy multiple examples to a target dir
23+
(),
24+
# 3a) user wants to copy all examples from a pack to cwd
25+
# 3b) user wants to copy all examples from a pack to a target dir
26+
(),
27+
# 4a) user wants to copy all examples from multiple packs to cwd
28+
# 4b) user wants to copy all examples from multiple packs to target dir
29+
(),
30+
# 5a) user wants to copy a combination of packs and examples to cwd
31+
# 5b) user wants to copy a combination of packs and examples to target
32+
(),
33+
# 6a) user wants to copy all examples from all packs to cwd
34+
# 6b) user wants to copy all examples from all packs to a target dir
35+
(),
36+
],
37+
)
38+
def test_copy_examples(input, to_cwd, expected, example_cases, target_dir):
39+
tmp_ex_dir = example_cases / input
40+
copytree(tmp_ex_dir, target_dir)
41+
# pkmg = PacksManager()
42+
# actual = cli.copy_examples(str(target_dir))
43+
assert False
44+
45+
1046
def test_print_info(temp_path, capsys):
1147
pkmg = PacksManager()
1248
actual = pkmg.available_examples(temp_path)
@@ -18,12 +54,7 @@ def test_print_info(temp_path, capsys):
1854
assert "Available packs" in output or "Installed packs" in output
1955

2056

21-
@pytest.mark.parametrize()
22-
def test_copy_examples(dict, tmp_path):
23-
cli.copy_examples(examples=dict, target_dir=tmp_path)
24-
assert False
25-
26-
57+
# NOTE: double check and remove these test after new above tests are made
2758
def test_map_pack_to_examples_structure():
2859
"""Test that map_pack_to_examples returns the right shape of
2960
data."""

0 commit comments

Comments
 (0)