def test_driver_reload(self): # Test reloading a driver. self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser1()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.driver_types_request' d_types, _ = core.invoke_command(com, {'driver_types': ['Dummy']}, self) com = u'hqc_meas.instr_manager.drivers_request' drivers, _ = core.invoke_command(com, {'drivers': ['PanelTestDummy']}, self) com = u'hqc_meas.instr_manager.reload_driver' re_driver = core.invoke_command(com, {'driver': 'PanelTestDummy'}, self) assert_is_not(re_driver, drivers['PanelTestDummy']) assert_equal(re_driver.__name__, 'PanelTestDummy') com = u'hqc_meas.instr_manager.driver_types_request' re_d_types, _ = core.invoke_command(com, {'driver_types': ['Dummy']}, self) assert_is_not(re_d_types['Dummy'], d_types['Dummy']) assert_equal(re_d_types['Dummy'].__name__, 'DummyInstrument')
def test_matching_drivers(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.matching_drivers' driver_names = core.invoke_command(com, {'driver_types': ['Dummy']}, self) assert_in('PanelTestDummy', driver_names)
def test_init(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(plugin.driver_types, ['Dummy']) assert_in('PanelTestDummy', plugin.drivers) assert_in('Dummy', plugin.all_profiles) assert_in('Dummy', plugin.available_profiles)
def test_load_all(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') plugin.drivers_loading = [] if plugin.report(): raise SkipTest(plugin.report())
def test_profiles_request3(self): # Test requesting profiles used by other users. Can't get profile not # released by user because of its policy. self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser1()) self.workbench.register(InstrUser3()) user1 = self.workbench.get_plugin(u'test.user1') user3 = self.workbench.get_plugin(u'test.user3') core = self.workbench.get_plugin(u'enaml.workbench.core') core.invoke_command(u'hqc_meas.instr_manager.profiles_request', {'profiles': [u'Dummy']}, user1) # Can get profile if other user release it. core.invoke_command(u'hqc_meas.instr_manager.profiles_request', {'profiles': [u'Dummy']}, user3) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(manager._used_profiles, {'Dummy': u'test.user3'}) # Don't get profile if other user does not release because of its # policy core.invoke_command(u'hqc_meas.instr_manager.profiles_request', {'profiles': [u'Dummy']}, user1) assert_equal(manager._used_profiles, {'Dummy': u'test.user3'}) core.invoke_command(u'hqc_meas.instr_manager.profiles_released', {'profiles': [u'Dummy']}, user3) self.workbench.unregister(u'test.user1') self.workbench.unregister(u'test.user3')
def test_profile_path1(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') path = plugin.profile_path('Dummy') assert_equal(path, os.path.join(self.test_dir, 'temp_profiles{}'.format(self.dir_id), 'dummy.ini'))
def test_matching_profiles(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.matching_profiles' [prof_name] = core.invoke_command(com, {'drivers': ['PanelTestDummy']}, self) assert_equal(prof_name, 'Dummy')
def test_matching_form3(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.matching_form' form, view = core.invoke_command(com, {'driver': '__xxxx__', 'view': True}, self) assert_equal(form, None) assert_equal(view.__name__, 'EmptyView')
def test_preventing_loading_package(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') plugin.drivers_loading.append('instruments.dummies') plugin._refresh_drivers() assert_not_in('PanelTestDummy', plugin.drivers) assert_in('Dummy', plugin.driver_types)
def test_dialog1(self): self.workbench.register(InstrManagerManifest()) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') form = ProfileForm(manager=manager) view = ProfileDialog(model=form, mode='new') del view view = ProfileDialog(model=form, mode='edit') del view
def test_driver_types_request2(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') invoke = core.invoke_command com = u'hqc_meas.instr_manager.driver_types_request' d_types, missing = invoke(com, {'driver_types': ['Dummy', 'N']}, self) assert_equal(missing, ['N']) assert_equal(d_types.keys(), ['Dummy'])
def test_user_management(self): self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser1()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(plugin._users.keys(), [u'test.user1']) self.workbench.register(InstrUser2()) assert_equal(sorted(plugin._users.keys()), sorted([u'test.user1', u'test.user2'])) self.workbench.unregister(u'test.user2') assert_equal(plugin._users.keys(), [u'test.user1'])
def test_driver_types_request1(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.driver_types_request' d_types, missing = core.invoke_command(com, {'driver_types': ['Dummy']}, self) assert_equal(d_types.keys(), ['Dummy']) assert_equal(d_types['Dummy'].__name__, 'DummyInstrument') assert_equal(missing, [])
def test_form1(self): self.workbench.register(InstrManagerManifest()) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') form = ProfileForm(manager=manager) form.driver_type = 'Dummy' assert_equal(form.drivers, manager.matching_drivers(['Dummy'])) assert isinstance(form.connection_form, DummyForm) assert_equal(form.dict(), { 'name': '', 'driver_type': 'Dummy', 'driver': '' })
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 = MeasDCVoltageTask(task_name='Test') self.root.children_task.append(self.task) self.root.run_time['drivers'] = {'Test': InstrHelper}
def setup(self): self.workbench = Workbench() self.workbench.register(CoreManifest()) self.workbench.register(UIManifest()) self.workbench.register(HqcAppManifest()) self.workbench.register(StateManifest()) self.workbench.register(PreferencesManifest()) self.workbench.register(LogManifest()) self.workbench.register(TaskManagerManifest()) self.workbench.register(InstrManagerManifest()) self.workbench.register(MeasureManifest()) self.workbench.register(TestSuiteManifest())
def setup(self): self.workbench = Workbench() self.workbench.register(CoreManifest()) self.workbench.register(UIManifest()) self.workbench.register(HqcAppManifest()) self.workbench.register(StateManifest()) self.workbench.register(PreferencesManifest()) self.workbench.register(LogManifest()) self.workbench.register(DependenciesManifest()) self.workbench.register(TaskManagerManifest()) self.workbench.register(InstrManagerManifest()) self.workbench.register(MeasureManifest()) self.workbench.register(TestSuiteManifest()) # Adding by hand the false instr task. plugin = self.workbench.get_plugin('hqc_meas.task_manager') plugin._py_tasks['False instr'] = FalseInstrTask
def test_profile_request5(self): # Test requesting profile by a non-registered user. self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser4()) core = self.workbench.get_plugin(u'enaml.workbench.core') user = self.workbench.get_plugin(u'test.user4') # Can't get profile without a valid user. cmd = u'hqc_meas.instr_manager.profiles_request' prof, miss = core.invoke_command(cmd, {'profiles': [u'N']}, user) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(manager.available_profiles, ['Dummy']) assert_equal(manager._used_profiles, {}) assert_equal(miss, []) assert_equal(prof, {})
def test_profile_request4(self): # Test requesting non-existing profiles. self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser1()) user = self.workbench.get_plugin(u'test.user1') core = self.workbench.get_plugin(u'enaml.workbench.core') # Can get profile. cmd = u'hqc_meas.instr_manager.profiles_request' _, miss = core.invoke_command(cmd, {'profiles': [u'N']}, user) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(manager.available_profiles, ['Dummy']) assert_equal(manager._used_profiles, {}) assert_equal(miss, [u'N']) self.workbench.unregister(u'test.user1')
def test_profile_observation(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_in('Dummy', plugin.all_profiles) assert_in('Dummy', plugin.available_profiles) profile_path = os.path.join(self.test_dir, 'temp_profiles{}'.format(self.dir_id)) prof = ConfigObj(os.path.join(profile_path, 'test.ini')) prof['driver_type'] = 'Dummy' prof['driver'] = 'PanelTestDummy' prof.write() try: from time import sleep sleep(0.5) process_app_events() assert_in(u'Test', plugin.all_profiles) assert_in(u'Test', plugin.available_profiles) finally: os.remove(os.path.join(profile_path, 'test.ini')) sleep(0.5) process_app_events() assert_not_in(u'Test', plugin.all_profiles) assert_not_in(u'Test', plugin.available_profiles)
def test_profile_request1(self): # Test basic profile request by registered user. self.workbench.register(InstrManagerManifest()) self.workbench.register(InstrUser1()) user = self.workbench.get_plugin(u'test.user1') core = self.workbench.get_plugin(u'enaml.workbench.core') # Can get profile. cmd = u'hqc_meas.instr_manager.profiles_request' profs, miss = core.invoke_command(cmd, {'profiles': [u'Dummy']}, user) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') assert_equal(manager.available_profiles, []) assert_equal(manager._used_profiles, {'Dummy': u'test.user1'}) # Can release profile. core.invoke_command(u'hqc_meas.instr_manager.profiles_released', {'profiles': ['Dummy']}, user) assert_equal(manager.available_profiles, ['Dummy']) assert_equal(manager._used_profiles, {}) self.workbench.unregister(u'test.user1')
def test_matching_form2(self): self.workbench.register(InstrManagerManifest()) core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.instr_manager.matching_form' form = core.invoke_command(com, {'driver': 'PanelTestDummy'}, self) assert_equal(form.__name__, 'DummyForm')
parser.add_argument("-s", "--nocapture", help="Don't capture stdout/stderr", action='store_false') args = parser.parse_args() workbench = Workbench() workbench.register(CoreManifest()) workbench.register(UIManifest()) workbench.register(HqcAppManifest()) workbench.register(StateManifest()) workbench.register(PreferencesManifest()) workbench.register(LogManifest()) workbench.register(DependenciesManifest()) workbench.register(TaskManagerManifest()) workbench.register(InstrManagerManifest()) workbench.register(MeasureManifest()) workbench.register(DebuggerManifest()) core = workbench.get_plugin('enaml.workbench.core') core.invoke_command('hqc_meas.logging.start_logging', {'std': args.nocapture}, workbench) core.invoke_command('enaml.workbench.ui.select_workspace', {'workspace': WORKSPACES[args.workspace]}, workbench) ui = workbench.get_plugin(u'enaml.workbench.ui') ui.show_window() ui.window.maximize() ui.start_application() workbench.unregister(u'hqc_meas.debug')
def test_profile_path2(self): self.workbench.register(InstrManagerManifest()) plugin = self.workbench.get_plugin(u'hqc_meas.instr_manager') path = plugin.profile_path('N') assert path is None
def test_form1(self): self.workbench.register(InstrManagerManifest()) manager = self.workbench.get_plugin(u'hqc_meas.instr_manager') view = InstrManagerView(manager=manager) del view