Skip to content

Commit 2e6b21b

Browse files
committed
Removed the need for an instance environment when determining the context of CLEM files; removed the corresponding mocks in the test
1 parent b1a165d commit 2e6b21b

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

src/murfey/client/analyser.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,9 @@ def _find_context(self, file_path: Path) -> bool:
127127
# Look for TIFF files associated with CLEM workflow
128128
# Leica's autosave mode seems to name the TIFFs in the format
129129
# PostionXX--ZXX--CXX.tif
130-
if (
131-
all(pattern in file_path.name for pattern in ("--Z", "--C"))
132-
and file_path.suffix in (".tiff", ".tif")
133-
and self._environment
134-
):
130+
if all(
131+
pattern in file_path.name for pattern in ("--Z", "--C")
132+
) and file_path.suffix in (".tiff", ".tif"):
135133
self._context = CLEMContext("leica", self._basepath)
136134
return True
137135

tests/client/test_analyser.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_mock import MockerFixture
54

65
from murfey.client.analyser import Analyser
76
from murfey.client.contexts.clem import CLEMContext
@@ -71,31 +70,12 @@
7170

7271

7372
@pytest.mark.parametrize("file_and_context", example_files)
74-
def test_find_context(mocker: MockerFixture, file_and_context, tmp_path):
73+
def test_find_context(file_and_context, tmp_path):
7574
# Unpack parametrised variables
7675
file_name, context = file_and_context
7776

78-
# The CLEM Context requires a MurfeyInstanceEnvironment
79-
if context is CLEMContext:
80-
# Mock the MurfeyInstanceEnvironment
81-
mock_environment = mocker.patch(
82-
"murfey.client.analyser.MurfeyInstanceEnvironment"
83-
)
84-
mock_environment.url.geturl.return_value = "https://murfey.server.test"
85-
mock_environment.instrument_name = "Test"
86-
mock_environment.demo = False
87-
88-
# Mock the call to get the machine config
89-
mocker.patch(
90-
"murfey.client.analyser.get_machine_config_client",
91-
return_value={"analyse_created_directories": ["images"]},
92-
)
93-
9477
# Pass the file to the Analyser; add environment as needed
95-
analyser = Analyser(
96-
basepath_local=tmp_path,
97-
environment=(mock_environment if context is CLEMContext else None),
98-
)
78+
analyser = Analyser(basepath_local=tmp_path)
9979

10080
# Check that the results are as expected
10181
assert analyser._find_context(tmp_path / file_name)

0 commit comments

Comments
 (0)