Skip to content

Commit 4b43de0

Browse files
Updating tests.
1 parent 6c8f64c commit 4b43de0

File tree

9 files changed

+161
-168
lines changed

9 files changed

+161
-168
lines changed

src/navigate/controller/sub_controllers/channels_tab_controller.py

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self, view, parent_controller=None):
122122
self.filter_wheel_delay = None
123123

124124
#: dict: The microscope state dictionary.
125-
self.microscope_state_dict = None
125+
self.microscope_state_dict = {}
126126

127127
# laser/stack cycling event binds
128128
self.stack_acq_vals["cycling"].trace_add("write", self.update_cycling_setting)
@@ -193,10 +193,6 @@ def initialize(self):
193193
def populate_experiment_values(self):
194194
"""Distribute initial MicroscopeState values to this and sub-controllers and
195195
associated views.
196-
197-
Examples
198-
--------
199-
>>> self.populate_experiment_values()
200196
"""
201197
self.in_initialization = True
202198
self.microscope_state_dict = self.parent_controller.configuration["experiment"][
@@ -313,11 +309,9 @@ def set_mode(self, mode):
313309
----------
314310
mode : str
315311
acquisition mode
316-
317-
Examples
318-
--------
319-
>>> self.set_mode(mode)
320312
"""
313+
314+
# TODO: Why do we have mode and image_mode?
321315
image_mode = self.microscope_state_dict["image_mode"]
322316
self.mode = mode
323317
self.channel_setting_controller.set_mode(mode)
@@ -375,10 +369,6 @@ def update_z_steps(self, *args):
375369
args : dict
376370
Values is a dict as follows {'step_size': 'start_position': ,
377371
'end_position': ,'number_z_steps'}
378-
379-
Examples
380-
--------
381-
>>> self.update_z_steps()
382372
"""
383373

384374
# won't do any calculation when initialization
@@ -463,10 +453,6 @@ def update_start_position(self, *args):
463453
args : dict
464454
Values is a dict as follows {'start_position': , 'abs_z_start': ,
465455
'stack_z_origin': }
466-
467-
Examples
468-
--------
469-
>>> self.update_start_position()
470456
"""
471457

472458
# We have a new origin
@@ -497,9 +483,6 @@ def update_end_position(self, *args):
497483
Values is a dict as follows {'end_position': , 'abs_z_end': ,
498484
'stack_z_origin': }
499485
500-
Examples
501-
--------
502-
>>> self.update_end_position()
503486
"""
504487
# Grab current values
505488
z_end = self.parent_controller.configuration["experiment"]["StageParameters"][
@@ -550,9 +533,6 @@ def update_cycling_setting(self, *args):
550533
Values is a dict as follows {'cycling_setting': , 'cycling_setting': ,
551534
'stack_z_origin': }
552535
553-
Examples
554-
--------
555-
>>> self.update_cycling_setting()
556536
"""
557537
# won't do any calculation when initializing
558538
if self.in_initialization:
@@ -579,10 +559,6 @@ def update_save_setting(self, *args):
579559
args : dict
580560
Values is a dict as follows {'save_data': , 'save_data': ,
581561
'stack_z_origin': }
582-
583-
Examples
584-
--------
585-
>>> self.update_save_setting()
586562
"""
587563

588564
if self.in_initialization:
@@ -610,9 +586,6 @@ def update_timepoint_setting(self, call_parent=False):
610586
call_parent : bool
611587
Tell parent controller that time point setting has changed.
612588
613-
Examples
614-
--------
615-
>>> self.update_timepoint_setting()
616589
"""
617590

618591
if self.in_initialization:
@@ -736,10 +709,6 @@ def toggle_multiposition(self):
736709
"""Toggle Multi-position Acquisition.
737710
738711
Recalculates the experiment duration.
739-
740-
Examples
741-
--------
742-
>>> self.toggle_multiposition()
743712
"""
744713
self.is_multiposition = self.is_multiposition_val.get()
745714
self.microscope_state_dict["is_multiposition"] = self.is_multiposition
@@ -767,10 +736,6 @@ def launch_tiling_wizard(self):
767736
768737
Will only launch when button in GUI is pressed, and will not duplicate.
769738
Pressing button again brings popup to top
770-
771-
Examples
772-
--------
773-
>>> self.launch_tiling_wizard()
774739
"""
775740

776741
if hasattr(self, "tiling_wizard_controller"):
@@ -788,11 +753,6 @@ def set_info(self, vals, values):
788753
List of variables to set.
789754
values : list
790755
List of values to set to variables.
791-
792-
Examples
793-
--------
794-
>>> self.set_info([self.timepoint_vals['timepoint_interval'],
795-
self.timepoint_vals['stack_pause']], [1, 1])
796756
"""
797757
for name in values.keys():
798758
if name in vals:
@@ -813,10 +773,6 @@ def execute(self, command, *args):
813773
-------
814774
command : object
815775
Returns parent_controller.execute(command) if command = 'get_stage_position'
816-
817-
Examples
818-
--------
819-
>>> self.execute('recalculate_timepoint')
820776
"""
821777
if command == "recalculate_timepoint":
822778
# update selected channels num
@@ -880,7 +836,7 @@ def set_exposure_time(self, channel, exposure_time):
880836
channel : str
881837
Channel name, such as "channel_1", "channel_2",...
882838
exposure_time : float
883-
Exposure time in miliseconds.
839+
Exposure time in milliseconds.
884840
"""
885841
idx = int(channel[channel.index("_") + 1 :]) - 1
886842
self.channel_setting_controller.in_initialization = True

test/config/test_config.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_config_methods():
7878
"verify_waveform_constants",
7979
"verify_configuration",
8080
"yaml",
81-
"build_ref_name"
81+
"build_ref_name",
8282
]
8383
for method in methods:
8484
assert method in desired_methods
@@ -101,8 +101,6 @@ def test_get_navigate_path_windows(monkeypatch):
101101
assert path_string.startswith("LOCALAPPDATA")
102102
assert path_string.endswith(".navigate")
103103

104-
105-
106104

107105
def test_get_navigate_path_mac(monkeypatch):
108106
"""Test that the Navigate path is a string."""
@@ -121,7 +119,7 @@ def test_get_configuration_paths():
121119
paths = config.get_configuration_paths()
122120
for path in paths:
123121
assert isinstance(path, pathlib.Path)
124-
assert len(paths) == 5
122+
assert len(paths) == 6
125123

126124

127125
def test_get_configuration_paths_create_dir(monkeypatch):
@@ -136,6 +134,7 @@ def test_get_configuration_paths_create_dir(monkeypatch):
136134
# delete generated folder
137135
delete_folder("TESTPATH")
138136

137+
139138
# test that the system is exited if no file is provided to load_yaml_config
140139
def test_load_yaml_config_no_file():
141140
"""Test that the system exits if no file is provided."""
@@ -362,9 +361,7 @@ def setUp(self):
362361
"waveform_template": "Default",
363362
}
364363

365-
multipositions_sample = [
366-
[10.0, 10.0, 10.0, 10.0, 10.0]
367-
]
364+
multipositions_sample = [[10.0, 10.0, 10.0, 10.0, 10.0]]
368365

369366
self.experiment_sample = {
370367
"Saving": saving_dict_sample,
@@ -669,8 +666,8 @@ def test_load_experiment_file_with_wrong_parameter_values(self):
669666
"defocus": 0.0,
670667
}
671668
]
672-
# number_of_filter_wheels =
673-
669+
# number_of_filter_wheels =
670+
674671
config.verify_experiment_config(self.manager, configuration)
675672
assert type(experiment["MicroscopeState"]["channels"]) is DictProxy
676673
assert len(list(experiment["MicroscopeState"]["channels"].keys())) == 0

test/controller/sub_controllers/test_acquire_bar_controller.py

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,7 @@
4545

4646

4747
class TestAcquireBarController:
48-
"""Tests for the AcquireBarController class
49-
50-
Attributes
51-
----------
52-
acqbarController : AcquireBarController
53-
Instance of the AcquireBarController class
54-
55-
Methods
56-
-------
57-
test_init()
58-
Tests the initialization of the AcquireBarController class
59-
test_attr()
60-
Tests the attributes of the AcquireBarController class
61-
test_set_save()
62-
Tests the set_save_option method of the AcquireBarController class
63-
test_stop_acquire()
64-
Tests the stop_acquire method of the AcquireBarController class
65-
test_populate_experiment_values()
66-
Tests the populate_experiment_values method of the AcquireBarController class
67-
"""
48+
"""Tests for the AcquireBarController class"""
6849

6950
@pytest.fixture(autouse=True)
7051
def setup_class(self, dummy_controller):
@@ -78,17 +59,12 @@ def setup_class(self, dummy_controller):
7859
c = dummy_controller
7960
v = dummy_controller.view
8061

81-
self.acquire_bar_controller = AcquireBarController(
82-
v.acqbar, c
83-
)
62+
self.acquire_bar_controller = AcquireBarController(v.acqbar, c)
8463
self.acquire_bar_controller.populate_experiment_values()
8564

8665
def test_init(self):
8766
"""Tests the initialization of the AcquireBarController class
8867
89-
90-
91-
9268
Raises
9369
------
9470
AssertionError
@@ -99,9 +75,6 @@ def test_init(self):
9975
def test_attr(self):
10076
"""Tests the attributes of the AcquireBarController class
10177
102-
103-
104-
10578
Raises
10679
------
10780
AssertionError
@@ -237,8 +210,12 @@ def test_get_set_mode(self, mode):
237210
test = self.acquire_bar_controller.get_mode()
238211
assert test == mode, "Mode not set correctly"
239212
# assert imaging mode is updated in the experiment
240-
assert self.acquire_bar_controller.parent_controller.configuration[
241-
"experiment"]["MicroscopeState"]["image_mode"] == mode
213+
assert (
214+
self.acquire_bar_controller.parent_controller.configuration["experiment"][
215+
"MicroscopeState"
216+
]["image_mode"]
217+
== mode
218+
)
242219

243220
def test_set_save(self):
244221
"""Tests the set_save method of the AcquireBarController class
@@ -313,8 +290,12 @@ def test_update_microscope_mode(self, user_mode, expected_mode):
313290

314291
# Checking that new mode gets set by function
315292
assert self.acquire_bar_controller.mode == expected_mode
316-
assert self.acquire_bar_controller.parent_controller.configuration[
317-
"experiment"]["MicroscopeState"]["image_mode"] == expected_mode
293+
assert (
294+
self.acquire_bar_controller.parent_controller.configuration["experiment"][
295+
"MicroscopeState"
296+
]["image_mode"]
297+
== expected_mode
298+
)
318299

319300
# Resetting to live
320301
self.acquire_bar_controller.view.pull_down.set("Continuous Scan")

test/controller/sub_controllers/test_autofocus_popup_controller.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
class TestAutofocusPopupController:
4646
"""Class for testing autofocus popup controller
4747
48-
Attributes
49-
----------
50-
af_controller : AutofocusPopupController
51-
Controller for autofocus popup
52-
5348
Methods
5449
-------
5550
test_init()
@@ -84,9 +79,6 @@ def setup_class(self, dummy_controller):
8479
def test_init(self):
8580
"""Tests that the controller is initialized correctly
8681
87-
88-
89-
9082
Raises
9183
------
9284
AssertionError
@@ -98,9 +90,6 @@ def test_init(self):
9890
def test_attr(self):
9991
"""Tests that the attributes are initialized correctly
10092
101-
102-
103-
10493
Raises
10594
------
10695
AssertionError
@@ -121,9 +110,6 @@ def test_attr(self):
121110
def test_populate_experiment_values(self):
122111
"""Tests that the values are populated correctly
123112
124-
125-
126-
127113
Raises
128114
------
129115
AssertionError
@@ -144,9 +130,6 @@ def test_populate_experiment_values(self):
144130
def test_update_experiment_values(self):
145131
"""Tests that the values are updated correctly
146132
147-
148-
149-
150133
Raises
151134
------
152135
AssertionError
@@ -183,9 +166,6 @@ def test_update_experiment_values(self):
183166
def test_start_autofocus(self):
184167
"""Tests that the start autofocus function works correctly
185168
186-
187-
188-
189169
Raises
190170
------
191171
AssertionError
@@ -207,9 +187,6 @@ def test_display_plot(self):
207187
Todo: Retrieve data from axessubplot instance and
208188
check that it is correct
209189
210-
211-
212-
213190
Raises
214191
------
215192
AssertionError

0 commit comments

Comments
 (0)