BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
microscope.testsuite.test_devices.LightSourceTests Class Reference
Inheritance diagram for microscope.testsuite.test_devices.LightSourceTests:
microscope.testsuite.test_devices.DeviceTests microscope.testsuite.test_devices.TestCoboltLaser microscope.testsuite.test_devices.TestCoherentSapphireLaser microscope.testsuite.test_devices.TestDummyLightSource microscope.testsuite.test_devices.TestOmicronDeepstarLaser

Public Member Functions

def assertEqualMW (self, first, second, msg=None)
 
def test_get_is_on (self)
 
def test_off_after_constructor (self)
 
def test_turning_on_and_off (self)
 
def test_shutdown (self)
 
def test_power_when_off (self)
 
def test_setting_power (self)
 
def test_setting_power_outside_limit (self)
 
def test_status (self)
 
- Public Member Functions inherited from microscope.testsuite.test_devices.DeviceTests
def test_on_and_off (self)
 
def test_enable_and_disable (self)
 
def test_enable_enabled (self)
 
def test_disable_disabled (self)
 

Detailed Description

Base class for :class:`LightSource` tests.

This class implements all the general laser tests and is meant to
be mixed with :class:`unittest.TestCase`.  Subclasses must
implement the `setUp` method which must add two properties:

`device`
    Instance of the :class:`LightSource` implementation being
    tested.

`fake`
    Object with a multiple attributes that specify the hardware
    and control the tests, such as the device max and min power
    values.  Such attributes may as well be attributes in the
    class that fakes the hardware.

Definition at line 159 of file test_devices.py.

Member Function Documentation

◆ assertEqualMW()

def microscope.testsuite.test_devices.LightSourceTests.assertEqualMW (   self,
  first,
  second,
  msg = None 
)

Definition at line 178 of file test_devices.py.

178 def assertEqualMW(self, first, second, msg=None):
179 # We could be smarter, but rounding the values should be
180 # enough to check the values when comparing power levels.
181 self.assertEqual(round(first), round(second), msg)
182

◆ test_get_is_on()

def microscope.testsuite.test_devices.LightSourceTests.test_get_is_on (   self)

Definition at line 183 of file test_devices.py.

183 def test_get_is_on(self):
184 self.assertEqual(self.device.connection.light, self.device.get_is_on())
185 self.device.enable()
186 self.assertEqual(self.device.connection.light, self.device.get_is_on())
187 self.device.disable()
188 self.assertEqual(self.device.connection.light, self.device.get_is_on())
189

◆ test_off_after_constructor()

def microscope.testsuite.test_devices.LightSourceTests.test_off_after_constructor (   self)

Definition at line 190 of file test_devices.py.

190 def test_off_after_constructor(self):
191 # Some lasers, such as our Coherent Sapphire emit laser
192 # radiation as soon as the key is switched on. We should
193 # ensure that the laser is turned off during the
194 # construction.
195 self.assertFalse(self.device.get_is_on())
196

◆ test_power_when_off()

def microscope.testsuite.test_devices.LightSourceTests.test_power_when_off (   self)

Definition at line 208 of file test_devices.py.

208 def test_power_when_off(self):
209 self.device.disable()
210 self.assertIsInstance(self.device.power, float)
211 self.assertEqual(self.device.power, 0.0)
212

◆ test_setting_power()

def microscope.testsuite.test_devices.LightSourceTests.test_setting_power (   self)

Definition at line 213 of file test_devices.py.

213 def test_setting_power(self):
214 self.device.enable()
215 self.assertIsInstance(self.device.power, float)
216 power_mw = self.device.power * self.fake.max_power
217 self.assertEqualMW(power_mw, self.fake.default_power)
218 self.assertEqualMW(self.device.power, self.device.get_set_power())
219
220 new_power = 0.5
221 new_power_mw = new_power * self.fake.max_power
222 self.device.power = new_power
223 self.assertEqualMW(
224 self.device.power * self.fake.max_power, new_power_mw
225 )
226 self.assertEqualMW(new_power, self.device.get_set_power())
227

◆ test_setting_power_outside_limit()

def microscope.testsuite.test_devices.LightSourceTests.test_setting_power_outside_limit (   self)

Definition at line 228 of file test_devices.py.

228 def test_setting_power_outside_limit(self):
229 self.device.enable()
230 self.device.power = -0.1
231 self.assertEqual(
232 self.device.power,
233 self.fake.min_power / self.fake.max_power,
234 "clip setting power below 0",
235 )
236 self.device.power = 1.1
237 self.assertEqual(self.device.power, 1.0, "clip setting power above 1")
238

◆ test_shutdown()

def microscope.testsuite.test_devices.LightSourceTests.test_shutdown (   self)

Definition at line 203 of file test_devices.py.

203 def test_shutdown(self):
204 self.device.enable()
205 self.device.disable()
206 self.device.shutdown()
207

◆ test_status()

def microscope.testsuite.test_devices.LightSourceTests.test_status (   self)

Definition at line 239 of file test_devices.py.

239 def test_status(self):
240 status = self.device.get_status()
241 self.assertIsInstance(status, list)
242 for msg in status:
243 self.assertIsInstance(msg, str)
244
245

◆ test_turning_on_and_off()

def microscope.testsuite.test_devices.LightSourceTests.test_turning_on_and_off (   self)

Definition at line 197 of file test_devices.py.

197 def test_turning_on_and_off(self):
198 self.device.enable()
199 self.assertTrue(self.device.get_is_on())
200 self.device.disable()
201 self.assertFalse(self.device.get_is_on())
202

The documentation for this class was generated from the following file: