|
1 | 1 | from pathlib import Path |
2 | 2 | from types import SimpleNamespace |
| 3 | +from unittest.mock import MagicMock |
3 | 4 |
|
4 | 5 | import pytest |
5 | 6 |
|
@@ -48,6 +49,11 @@ def controller(tk_root): |
48 | 49 | waveform_templates_path, |
49 | 50 | args, |
50 | 51 | ) |
| 52 | + # To make sure the testcases won't hang on because of the model.event_queue |
| 53 | + # The changes here won't affect other testcases, |
| 54 | + # because the testcases from other files use DummyController and DummyModel instead of this controller fixture |
| 55 | + controller.model = MagicMock() |
| 56 | + controller.model.get_offset_variance_maps.return_value = (None, None) |
51 | 57 |
|
52 | 58 | yield controller |
53 | 59 |
|
@@ -89,3 +95,43 @@ def test_prepare_acquire_data(controller): |
89 | 95 | def test_execute(controller): |
90 | 96 | controller.execute("acquire", "single") |
91 | 97 | assert True |
| 98 | + |
| 99 | + |
| 100 | +@pytest.mark.parametrize( |
| 101 | + "acquisition_mode, sensor_mode, readout_direction, template_name, expected_template_name", |
| 102 | + [ |
| 103 | + ("live", "Normal", "", "Bidirectional", "Default"), |
| 104 | + ("z-stack", "Normal", "", "Bidirectional", "Default"), |
| 105 | + ("customized", "Normal", "", "Bidirectional", "Bidirectional"), |
| 106 | + ("live", "Light-Sheet", "Top-To-Bottom", "Bidirectional", "Default"), |
| 107 | + ("live", "Light-Sheet", "Bidirectional", "Bidirectional", "Bidirectional"), |
| 108 | + ("customized", "Light-Sheet", "Bidirectional", "Bidirectional", "Bidirectional",), |
| 109 | + ("z-stack", "Light-Sheet", "Bidirectional", "Default", "Bidirectional"), |
| 110 | + ("z-stack", "Light-Sheet", "Top-To-Bottom", "Default", "Default"), |
| 111 | + ], |
| 112 | +) |
| 113 | +def test_waveform_template( |
| 114 | + controller, |
| 115 | + acquisition_mode, |
| 116 | + sensor_mode, |
| 117 | + readout_direction, |
| 118 | + template_name, |
| 119 | + expected_template_name, |
| 120 | +): |
| 121 | + controller.configuration["experiment"]["MicroscopeState"][ |
| 122 | + "waveform_template" |
| 123 | + ] = template_name |
| 124 | + controller.configuration["experiment"]["MicroscopeState"][ |
| 125 | + "image_mode" |
| 126 | + ] = acquisition_mode |
| 127 | + controller.configuration["experiment"]["CameraParameters"]["number_of_pixels"] = 10 |
| 128 | + controller.populate_experiment_setting(in_initialize=True) |
| 129 | + |
| 130 | + controller.camera_setting_controller.mode_widgets["Readout"].set(readout_direction) |
| 131 | + controller.camera_setting_controller.mode_widgets["Sensor"].set(sensor_mode) |
| 132 | + controller.update_experiment_setting() |
| 133 | + |
| 134 | + assert ( |
| 135 | + controller.configuration["experiment"]["MicroscopeState"]["waveform_template"] |
| 136 | + == expected_template_name |
| 137 | + ) |
0 commit comments