Skip to content

Commit 00508df

Browse files
committed
Added tests for the 'limited' logic block in '_analyse'
1 parent 7852f04 commit 00508df

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/client/test_analyser.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,42 @@ def test_analyse_sxt(
261261
assert mock_post_transfer.call_count == len(test_files)
262262

263263

264+
@pytest.mark.parametrize(
265+
"test_params",
266+
[
267+
["SPAMetadataContext", ["AtlasContext", "SPAContext"]],
268+
["TomographyMetadataContext", ["AtlasContext", "SPAContext"]],
269+
],
270+
)
271+
def test_analyse_limited(
272+
mocker: MockerFixture, tmp_path: Path, test_params: tuple[str, list[str]]
273+
):
274+
# Unpack test params
275+
expected_context, other_contexts = test_params
276+
277+
# Load example files related to the CLEM
278+
test_files = [
279+
file
280+
for context, file_list in example_files.items()
281+
for file in file_list
282+
if context in (expected_context, *other_contexts)
283+
]
284+
285+
# Mock the 'post_transfer' class function
286+
mock_post_transfer = mocker.patch.object(Analyser, "post_transfer")
287+
288+
# Initialise the Analyser
289+
analyser = Analyser(tmp_path, "", limited=True)
290+
for file in test_files:
291+
analyser._analyse(tmp_path / file)
292+
293+
# "_find_context" should be called only once
294+
assert analyser._context is not None and expected_context in str(analyser._context)
295+
296+
# "_post_transfer" should be called on every one of these files
297+
assert mock_post_transfer.call_count == len(test_files)
298+
299+
264300
def test_analyse_spa():
265301
pass
266302

0 commit comments

Comments
 (0)