|
1 | | -import os |
2 | | -from pathlib import Path |
3 | | - |
4 | 1 | import pytest |
5 | 2 |
|
6 | 3 | from diffpy.cmi import cli |
@@ -144,62 +141,3 @@ def test_copy_examples( |
144 | 141 | subset = select_examples_subset(examples_dict, copy_type) |
145 | 142 | cli.copy_examples(subset, target_dir=target_dir) |
146 | 143 | verify_copied_files(subset, target_dir, case_dir) |
147 | | - |
148 | | - |
149 | | -def test_map_pack_to_examples_structure(): |
150 | | - """Test that map_pack_to_examples returns the right shape of |
151 | | - data.""" |
152 | | - actual = cli.map_pack_to_examples() |
153 | | - assert isinstance(actual, dict) |
154 | | - for pack, exdirs in actual.items(): |
155 | | - assert isinstance(pack, str) |
156 | | - assert isinstance(exdirs, list) |
157 | | - for ex in exdirs: |
158 | | - assert isinstance(ex, str) |
159 | | - # Check for known packs |
160 | | - assert "core" in actual.keys() |
161 | | - assert "pdf" in actual.keys() |
162 | | - # Check for known examples |
163 | | - assert ["linefit"] in actual.values() |
164 | | - |
165 | | - |
166 | | -@pytest.mark.parametrize( |
167 | | - "input_valid_str", |
168 | | - [ |
169 | | - "core/linefit", |
170 | | - "pdf/ch03NiModelling", |
171 | | - ], |
172 | | -) |
173 | | -def test_copy_example_success(tmp_path, input_valid_str): |
174 | | - """Given a valid example format (<pack>/<ex>), test that its copied |
175 | | - to the temp dir.""" |
176 | | - os.chdir(tmp_path) |
177 | | - actual = cli.copy_example(input_valid_str) |
178 | | - expected = tmp_path / Path(input_valid_str).name |
179 | | - assert expected.exists() and expected.is_dir() |
180 | | - assert actual == expected |
181 | | - |
182 | | - |
183 | | -def test_copy_example_fnferror(): |
184 | | - """Test that FileNotFoundError is raised when the example does not |
185 | | - exist.""" |
186 | | - with pytest.raises(FileNotFoundError): |
187 | | - cli.copy_example("pack/example1") |
188 | | - |
189 | | - |
190 | | -@pytest.mark.parametrize( |
191 | | - "input_bad_str", |
192 | | - [ |
193 | | - "", # empty string |
194 | | - "/", # missing pack and example |
195 | | - "corelinefit", # missing slash |
196 | | - "linefit", # missing pack and slash |
197 | | - "core/", # missing example |
198 | | - "/linefit", # missing pack |
199 | | - "core/linefit/extra", # too many slashes |
200 | | - ], |
201 | | -) |
202 | | -def test_copy_example_valueerror(input_bad_str): |
203 | | - """Test that ValueError is raised when the format is invalid.""" |
204 | | - with pytest.raises(ValueError): |
205 | | - cli.copy_example(input_bad_str) |
0 commit comments