Skip to content

Commit 7e00b7e

Browse files
committed
Added test for the '_find_extension' class function
1 parent fb07598 commit 7e00b7e

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

tests/client/test_analyser.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@
7070
}
7171

7272

73+
@pytest.mark.parametrize(
74+
"test_file",
75+
[
76+
file
77+
for file_list in example_files.values()
78+
for file in file_list
79+
for suffix in (".mrc", ".tiff", ".tif", ".eer", ".lif", ".txrm", ".xrm")
80+
if file.endswith(suffix)
81+
],
82+
)
83+
def test_find_extension(test_file: str, tmp_path: Path):
84+
analyser = Analyser(basepath_local=tmp_path, token="")
85+
# Pass the file to the function, and check the outputs are as expected
86+
assert analyser._find_extension(tmp_path / test_file)
87+
assert test_file.endswith(analyser._extension)
88+
89+
7390
@pytest.mark.parametrize(
7491
"file_and_context",
7592
[
@@ -82,14 +99,14 @@ def test_find_context(file_and_context, tmp_path):
8299
# Unpack parametrised variables
83100
file_name, context = file_and_context
84101

85-
# Pass the file to the Analyser; add environment as needed
102+
# Set up the Analyser
86103
analyser = Analyser(basepath_local=tmp_path, token="")
87104

88-
# Check that the results are as expected
105+
# Pass the file to the function, and check that outputs are as expected
89106
assert analyser._find_context(tmp_path / file_name)
90107
assert analyser._context is not None and context in str(analyser._context)
91108

92-
# Checks for the specific workflow contexts
109+
# Additional checks for specific contexts
93110
if isinstance(analyser._context, TomographyContext):
94111
assert analyser.parameters_model == ProcessingParametersTomo
95112
if isinstance(analyser._context, SPAContext):

0 commit comments

Comments
 (0)