class ProgressWidgetHandlerTests(unittest.TestCase): """ Tests for the :class:`gui.calibration.progress.ProgressWidgetHandler` class. """ def setUp(self): self.mediator = gui.mediator.Mediator(logging=True) self.system = ops.system.ProductionSystem(self.mediator) self.handler = ProgressWidgetHandler(self.system) def startCalibration(self): """Sends a synthetic :class:`CalibrationStarted` event.""" self.mediator.noteEvent(CalibrationStarted(self.system, 'dummy')) def endCalibration(self): """Sends a synthetic :class:`CalibrationOver` event.""" self.mediator.noteEvent( CalibrationOver(self.system, 'dummy', 'dummy', 'dummy', 'dummy')) def testGC(self): """Make sure the class is properly garbage-collected.""" wr = weakref.ref(self.handler) self.handler = None gc.collect() self.assertEqual(wr(), None) def testWidget(self): """Tests the :attr:`widget` property.""" self.assertTrue(isinstance(self.handler.widget, gtk.Widget)) self.assertRaises(AttributeError, setattr, self.handler, 'widget', 0) def testTimeout(self): """Checks that a timeout is added when the calibration is started.""" self.handler.updateInterval = 60000 self.startCalibration() self.assertEqual(self.mediator.timeoutsAdded[-1][0], 60000) def testUpdateCalibrationOver(self): """ Tests the :meth:`_update` method when the calibration is over. """ self.startCalibration() self.endCalibration() self.assertFalse(self.handler._update())
def setUp(self): self.mediator = gui.mediator.Mediator(logging=True) self.system = ops.system.ProductionSystem(self.mediator) self.handler = ProgressWidgetHandler(self.system)