def setup(self): self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFPowerTask(task_name='Test') self.root.children_task.append(self.task) self.root.run_time['drivers'] = {'Test': InstrHelper} # This is set simply to make sure the test of InstrTask pass. self.task.selected_driver = 'Test' self.task.selected_profile = 'Test1'
class TestPNASetRFPowerTask(object): def setup(self): self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFPowerTask(task_name='Test') self.root.children_task.append(self.task) self.root.run_time['drivers'] = {'Test': InstrHelper} # This is set simply to make sure the test of InstrTask pass. self.task.selected_driver = 'Test' self.task.selected_profile = 'Test1' def test_check_pna_interface1(self): # Simply test that everything is ok if power can be evaluated. self.task.interface = PNASetRFPowerInterface(task=self.task, channel=1) self.task.power = '1.0' profile = {'Test1': ({'defined_channels': [[1]]}, {})} self.root.run_time['profiles'] = profile test, traceback = self.task.check(test_instr=True) assert_true(test) assert_false(traceback) def test_check_pna_interface2(self): # Check handling a wrong channel. self.task.interface = PNASetRFPowerInterface(task=self.task, channel=2) self.task.power = '1.0' profile = {'Test1': ({'defined_channels': [[1]]}, {})} self.root.run_time['profiles'] = profile test, traceback = self.task.check(test_instr=True) assert_false(test) assert_equal(len(traceback), 1) def test_perform_pna_interface(self): self.task.interface = PNASetRFPowerInterface(task=self.task, channel=1) self.task.power = '1.0' profile = {'Test1': ({'power': [0.0], 'port': [1], 'owner': [None]}, {'get_channel': lambda x, i: x} )} self.root.run_time['profiles'] = profile self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_power'), 1.0)
class TestPNASetRFPowerTask(object): def setup(self): self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFPowerTask(task_name='Test') self.root.children_task.append(self.task) self.root.run_time['drivers'] = {'Test': InstrHelper} # This is set simply to make sure the test of InstrTask pass. self.task.selected_driver = 'Test' self.task.selected_profile = 'Test1' def test_check_pna_interface1(self): # Simply test that everything is ok if power can be evaluated. self.task.interface = PNASetRFPowerInterface(task=self.task, channel=1) self.task.power = '1.0' profile = {'Test1': ({'defined_channels': [[1]]}, {})} self.root.run_time['profiles'] = profile test, traceback = self.task.check(test_instr=True) assert_true(test) assert_false(traceback) def test_check_pna_interface2(self): # Check handling a wrong channel. self.task.interface = PNASetRFPowerInterface(task=self.task, channel=2) self.task.power = '1.0' profile = {'Test1': ({'defined_channels': [[1]]}, {})} self.root.run_time['profiles'] = profile test, traceback = self.task.check(test_instr=True) assert_false(test) assert_equal(len(traceback), 1) def test_perform_pna_interface(self): self.task.interface = PNASetRFPowerInterface(task=self.task, channel=1) self.task.power = '1.0' profile = { 'Test1': ({ 'power': [0.0], 'port': [1], 'owner': [None] }, { 'get_channel': lambda x, i: x }) } self.root.run_time['profiles'] = profile self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_power'), 1.0)
def setup(self): self.workbench = Workbench() self.workbench.register(CoreManifest()) self.workbench.register(StateManifest()) self.workbench.register(PreferencesManifest()) self.workbench.register(InstrManagerManifest()) self.workbench.register(TaskManagerManifest()) self.root = RootTask(should_stop=Event(), should_pause=Event()) self.task = SetRFPowerTask(task_name='Test') self.root.children_task.append(self.task) self.root.run_time['drivers'] = {'Test': InstrHelper}