Example #1
0
    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(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 setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(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'
Example #3
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 = ApplyMagFieldTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}
class TestApplyMagFieldTask(object):

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(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_check1(self):
        # Simply test that everything is ok if field can be evaluated.
        self.task.target_field = '3.0'

        test, traceback = self.task.check(test_instr=True)
        assert_true(test)
        assert_false(traceback)

        assert_equal(self.task.get_from_database('Test_Bfield'), 3.0)

    def test_check2(self):
        # Check handling a wrong field.
        self.task.target_field = '*1.0*'

        test, traceback = self.task.check(test_instr=True)
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test-field', traceback)

        assert_equal(self.task.get_from_database('Test_Bfield'), 0.01)

    def test_perform1(self):
        # Simple test when everything is right.
        self.task.target_field = '2.0'

        self.root.run_time['profiles'] = {'Test1': ({'owner': []},
                                                    {'make_ready': [None],
                                                     'go_to_field': [None]}
                                                    )}

        self.root.task_database.prepare_for_running()

        self.task.perform()
        join_threads(self.root)
        assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)

    def test_perform2(self):
        # Test multiple run when connection is maintained.
        self.task.target_field = '2.0'

        self.root.run_time['profiles'] = {'Test1': ({'owner': []},
                                                    {'make_ready': [None],
                                                     'go_to_field': [None],
                                                     'check_connection': [True]
                                                     }
                                                    )}

        self.root.task_database.prepare_for_running()

        self.task.perform()
        join_threads(self.root)
        self.task.perform()
        join_threads(self.root)
        # In case of fail make_ready would be called twice.
        assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)
Example #5
0
class TestApplyMagFieldTask(object):
    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(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_check1(self):
        # Simply test that everything is ok if field can be evaluated.
        self.task.target_field = '3.0'

        test, traceback = self.task.check(test_instr=True)
        assert_true(test)
        assert_false(traceback)

        assert_equal(self.task.get_from_database('Test_Bfield'), 3.0)

    def test_check2(self):
        # Check handling a wrong field.
        self.task.target_field = '*1.0*'

        test, traceback = self.task.check(test_instr=True)
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test-field', traceback)

        assert_equal(self.task.get_from_database('Test_Bfield'), 0.01)

    def test_perform1(self):
        # Simple test when everything is right.
        self.task.target_field = '2.0'

        self.root.run_time['profiles'] = {
            'Test1': ({
                'owner': []
            }, {
                'make_ready': [None],
                'go_to_field': [None]
            })
        }

        self.root.task_database.prepare_for_running()

        self.task.perform()
        join_threads(self.root)
        assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)

    def test_perform2(self):
        # Test multiple run when connection is maintained.
        self.task.target_field = '2.0'

        self.root.run_time['profiles'] = {
            'Test1': ({
                'owner': []
            }, {
                'make_ready': [None],
                'go_to_field': [None],
                'check_connection': [True]
            })
        }

        self.root.task_database.prepare_for_running()

        self.task.perform()
        join_threads(self.root)
        self.task.perform()
        join_threads(self.root)
        # In case of fail make_ready would be called twice.
        assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)