Skip to content

Commit 75b02ba

Browse files
committed
checkpoint 2
1 parent 238da57 commit 75b02ba

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def user_filesystem(tmp_path):
2424
)
2525
binary_data = b"\x00\x01\x02\x03\x04"
2626

27+
with open(base_dir / "data.chi", "w") as f:
28+
f.write(chi_data)
29+
with open(base_dir / "data_corrected.chi", "w") as f:
30+
f.write(chi_data)
2731
with open(base_dir / "good_data.chi", "w") as f:
2832
f.write(chi_data)
2933
with open(base_dir / "good_data.xy", "w") as f:

tests/test_labpdfprocapp.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
from diffpy.labpdfproc.labpdfprocapp import (
4+
apply_absorption_correction,
5+
get_args_cli,
6+
)
7+
8+
9+
# Case: user tries to run absorption correction, but the output
10+
# filename already exists.
11+
# expected: the function should raise a FileExistsError, telling the
12+
# user that the output
13+
# file already exists and asking if they want to overwrite it.
14+
def test_file_exists_error(user_filesystem):
15+
input_data_file = str(user_filesystem / "data.chi")
16+
existing_corrected_file = str(user_filesystem / "data_corrected.chi")
17+
18+
cli_inputs = ["mud"] + [input_data_file] + ["2.5"]
19+
args = get_args_cli(cli_inputs)
20+
# assert args == []
21+
msg = (
22+
"The following output files already exist:"
23+
f"\n{existing_corrected_file}\n"
24+
"Use --force to overwrite them."
25+
)
26+
with pytest.raises(FileExistsError, match=msg):
27+
apply_absorption_correction(args)

0 commit comments

Comments
 (0)