Skip to content

Commit a76e2d0

Browse files
committed
Added test for atlas analysis and SPA analysis
1 parent 00508df commit a76e2d0

1 file changed

Lines changed: 62 additions & 2 deletions

File tree

tests/client/test_analyser.py

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,68 @@ def test_analyse_limited(
297297
assert mock_post_transfer.call_count == len(test_files)
298298

299299

300-
def test_analyse_spa():
301-
pass
300+
def test_analyse_atlas(
301+
mocker: MockerFixture,
302+
tmp_path: Path,
303+
):
304+
test_files = [
305+
file
306+
for context, file_list in example_files.items()
307+
for file in file_list
308+
if context == "AtlasContext"
309+
]
310+
311+
# Mock the 'post_transfer' class function
312+
mock_post_transfer = mocker.patch.object(Analyser, "post_transfer")
313+
spy_find_context = mocker.spy(Analyser, "_find_context")
314+
315+
# Initialise the Analyser
316+
analyser = Analyser(tmp_path, "", force_mdoc_metadata=True)
317+
for file in test_files:
318+
analyser._analyse(tmp_path / file)
319+
320+
# Context should be set
321+
assert analyser._context is not None and "AtlasContext" in str(analyser._context)
322+
323+
# "_find_context" should be called once
324+
assert spy_find_context.call_count == 1
325+
326+
# "post_transfer" should be called on all files
327+
assert mock_post_transfer.call_count == len(test_files)
328+
329+
330+
@pytest.mark.parametrize(
331+
"context_to_test",
332+
("SPAContext", "SPAMetadataContext"),
333+
)
334+
def test_analyse_spa(
335+
mocker: MockerFixture,
336+
context_to_test: str,
337+
tmp_path: Path,
338+
):
339+
test_files = [
340+
file
341+
for context, file_list in example_files.items()
342+
for file in file_list
343+
if context == context_to_test
344+
]
345+
346+
# Mock the 'post_transfer' class function
347+
mock_post_transfer = mocker.patch.object(Analyser, "post_transfer")
348+
spy_find_context = mocker.spy(Analyser, "_find_context")
349+
spy_find_extension = mocker.spy(Analyser, "_find_extension")
350+
351+
# Initialise the Analyser
352+
analyser = Analyser(tmp_path, "", force_mdoc_metadata=True)
353+
for file in test_files:
354+
analyser._analyse(tmp_path / file)
355+
356+
assert spy_find_context.call_count == 1
357+
assert analyser._context is not None and context_to_test in str(analyser._context)
358+
if context_to_test == "SPAContext":
359+
assert spy_find_extension.call_count > 0
360+
assert analyser._extension in (".eer", ".tiff")
361+
mock_post_transfer.assert_called()
302362

303363

304364
def test_analyse_tomo():

0 commit comments

Comments
 (0)