Skip to content

Commit 1121cf6

Browse files
committed
fix tests
1 parent 78e6136 commit 1121cf6

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

test/controller/sub_controllers/test_camera_settings.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,23 @@ def test_attr(self):
183183
assert hasattr(self.camera_settings, attr)
184184

185185
def test_populate_experiment_values(self):
186+
microscope_name = self.camera_settings.parent_controller.configuration[
187+
"experiment"
188+
]["MicroscopeState"]["microscope_name"]
186189
self.camera_settings.parent_controller.configuration["experiment"][
187190
"CameraParameters"
188-
]["readout_time"] = 0.1
191+
][microscope_name]["readout_time"] = 0.1
189192
# Populate widgets with values from experiment file and check
190193
self.camera_settings.populate_experiment_values()
191194
camera_setting_dict = self.camera_settings.parent_controller.configuration[
192195
"experiment"
193-
]["CameraParameters"]
196+
]["CameraParameters"][microscope_name]
194197

195198
# Checking values altered are correct
196199
assert dict(self.camera_settings.camera_setting_dict) == dict(
197200
self.camera_settings.parent_controller.configuration["experiment"][
198201
"CameraParameters"
199-
]
202+
][microscope_name]
200203
)
201204
assert (
202205
str(self.camera_settings.mode_widgets["Sensor"].get())
@@ -228,14 +231,12 @@ def test_populate_experiment_values(self):
228231
== camera_setting_dict["y_pixels"]
229232
)
230233

231-
assert (
232-
self.camera_settings.roi_widgets["Top_X"].get()
233-
== camera_setting_dict.get("top_x", 0)
234-
)
235-
assert (
236-
self.camera_settings.roi_widgets["Top_Y"].get()
237-
== camera_setting_dict.get("top_y", 0)
238-
)
234+
assert self.camera_settings.roi_widgets[
235+
"Top_X"
236+
].get() == camera_setting_dict.get("top_x", 0)
237+
assert self.camera_settings.roi_widgets[
238+
"Top_Y"
239+
].get() == camera_setting_dict.get("top_y", 0)
239240
if camera_setting_dict.get("is_centered", True):
240241
assert (
241242
str(self.camera_settings.roi_widgets["Top_X"].widget["state"])
@@ -253,7 +254,9 @@ def test_populate_experiment_values(self):
253254
)
254255

255256
# Exposure Time
256-
channels = self.camera_settings.microscope_state_dict["channels"]
257+
channels = self.camera_settings.parent_controller.configuration["experiment"][
258+
"MicroscopeState"
259+
]["channels"]
257260
exposure_time = channels[list(channels.keys())[0]]["camera_exposure_time"]
258261
assert (
259262
self.camera_settings.framerate_widgets["exposure_time"].get()
@@ -268,11 +271,14 @@ def test_populate_experiment_values(self):
268271
@pytest.mark.parametrize("mode", ["Normal", "Light-Sheet"])
269272
def test_update_experiment_values(self, mode):
270273

274+
microscope_name = self.camera_settings.parent_controller.configuration[
275+
"experiment"
276+
]["MicroscopeState"]["microscope_name"]
271277
# Setup basic default experiment
272278
self.camera_settings.camera_setting_dict = (
273279
self.camera_settings.parent_controller.configuration["experiment"][
274280
"CameraParameters"
275-
]
281+
][microscope_name]
276282
)
277283

278284
# Setting up new values in widgets
@@ -329,9 +335,12 @@ def test_update_experiment_values(self, mode):
329335
@pytest.mark.parametrize("mode", ["Normal", "Light-Sheet"])
330336
def test_update_sensor_mode(self, mode):
331337
self.camera_settings.populate_experiment_values()
338+
microscope_name = self.camera_settings.parent_controller.configuration[
339+
"experiment"
340+
]["MicroscopeState"]["microscope_name"]
332341
camera_setting_dict = self.camera_settings.parent_controller.configuration[
333342
"experiment"
334-
]["CameraParameters"]
343+
]["CameraParameters"][microscope_name]
335344

336345
# Set mode
337346
self.camera_settings.mode_widgets["Sensor"].widget.set(mode)

test/model/features/test_restful_features.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def setUp(self):
100100
"rest_api_config": {"Ilastik": {"url": "http://example.com/ilastik"}},
101101
"experiment": {
102102
"MicroscopeState": {"microscope_name": "Nanoscale", "zoom": "1.0"},
103-
"CameraParameters": {"x_pixels": "2048", "y_pixels": "2048"},
103+
"CameraParameters": {
104+
"Nanoscale": {"x_pixels": "2048", "y_pixels": "2048"},
105+
},
104106
"StageParameters": {
105107
"x": "100",
106108
"y": "100",
@@ -125,6 +127,7 @@ def setUp(self):
125127
self.mock_model.display_ilastik_segmentation = True
126128
self.mock_model.mark_ilastik_position = False
127129
self.mock_model.event_queue = MagicMock()
130+
self.mock_model.active_microscope_name = "Nanoscale"
128131

129132
self.ilastik_segmentation = IlastikSegmentation(self.mock_model)
130133

test/model/features/test_volume_search.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ def test_box_volume_search(self):
198198
from navigate.tools.sdf import volume_from_sdf, box
199199

200200
M = int(self.config["number_z_steps"])
201-
self.model.configuration["experiment"]["CameraParameters"]["x_pixels"] = self.N
201+
microscope_name = self.model.configuration["experiment"]["MicroscopeState"][
202+
"microscope_name"
203+
]
204+
self.model.configuration["experiment"]["CameraParameters"][microscope_name][
205+
"x_pixels"
206+
] = self.N
202207
self.lxy = (
203208
np.random.randint(int(0.1 * self.N), int(0.4 * self.N))
204209
* self.curr_pixel_size

test/model/metadata_sources/test_metadata.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ def test_metadata_shape(dummy_model):
4141

4242
md.configuration = dummy_model.configuration
4343

44-
txs = dummy_model.configuration["experiment"]["CameraParameters"]["img_x_pixels"]
45-
tys = dummy_model.configuration["experiment"]["CameraParameters"]["img_y_pixels"]
44+
microscope_name = dummy_model.configuration["experiment"]["MicroscopeState"][
45+
"microscope_name"
46+
]
47+
txs = dummy_model.configuration["experiment"]["CameraParameters"][microscope_name][
48+
"img_x_pixels"
49+
]
50+
tys = dummy_model.configuration["experiment"]["CameraParameters"][microscope_name][
51+
"img_y_pixels"
52+
]
4653
tzs = dummy_model.configuration["experiment"]["MicroscopeState"]["number_z_steps"]
4754
tts = dummy_model.configuration["experiment"]["MicroscopeState"]["timepoints"]
4855
tcs = sum(

0 commit comments

Comments
 (0)