class TestSetRFOnOffTask(object): def setup(self): self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFOnOffTask(name='Test') self.root.add_child_task(0, self.task) self.root.run_time[DRIVERS] = {'Test': (InstrHelper, InstrHelperStarter())} self.root.run_time[PROFILES] =\ {'Test1': {'connections': {'C': {'owner': []}}, 'settings': {'S': {'check_connection': [True]}} } } # This is set simply to make sure the test of InstrTask pass. self.task.selected_instrument = ('Test1', 'Test', 'C', 'S') def test_check_base_interface1(self): # Simply test that everything is ok if voltage can be evaluated. self.task.switch = '1.0' test, traceback = self.task.check(test_instr=True) assert test assert not traceback def test_check_base_interface2(self): # Check handling a wrong voltage. self.task.switch = '*1.0*' test, traceback = self.task.check(test_instr=True) assert not test assert len(traceback) == 1 def test_perform_base_interface(self): self.task.switch = '1.0' c = self.root.run_time[PROFILES]['Test1']['connections'] c['C'] = {'output': [0.0], 'owner': [None]} self.root.prepare() self.task.perform() assert self.root.get_from_database('Test_output') == 1.0
def setup(self): self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFOnOffTask(name='Test') self.root.add_child_task(0, self.task) self.root.run_time[DRIVERS] = {'Test': (InstrHelper, InstrHelperStarter())} self.root.run_time[PROFILES] =\ {'Test1': {'connections': {'C': {'owner': []}}, 'settings': {'S': {'check_connection': [True]}} } } # This is set simply to make sure the test of InstrTask pass. self.task.selected_instrument = ('Test1', 'Test', 'C', 'S')