def test_remove_monitor2(self): """ Test removing a non-existent monitor (should be a no-op). """ plugin = self.workbench.get_plugin(u'hqc_meas.measure') measure = Measure(plugin=plugin, name='Test', status='Under test') measure.root_task = RootTask() measure.remove_monitor(u'monitor1')
def test_remove_monitor1(self): """ Test removing a monitor. """ plugin = self.workbench.get_plugin(u'hqc_meas.measure') measure = Measure(plugin=plugin, name='Test', status='Under test') measure.root_task = RootTask() test_obs = lambda change: False measure.root_task.task_database.observe('notifier', test_obs) monitor_decl = plugin.monitors[u'monitor1'] measure.add_monitor(monitor_decl.id, monitor_decl.factory(monitor_decl, self.workbench)) measure.remove_monitor(u'monitor1') assert_not_in(u'monitor1', measure.monitors) # Check that the notifier is not observed anymore but that other # observers are not deleted. assert_true(measure.root_task.task_database.has_observers('notifier')) measure.root_task.task_database.unobserve('notifier', test_obs) assert_false(measure.root_task.task_database.has_observers('notifier'))