コード例 #1
0
    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = DefinitionTask(task_name='Test')
        self.root.children_task.append(self.task)
コード例 #2
0
class TestDefinitionTask(object):

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = DefinitionTask(task_name='Test')
        self.root.children_task.append(self.task)

    def test_definitions_observation(self):
        # Test that the database is correctly updated when defs change.
        self.task.definitions = [('1', '2.0'), ('2', "['a', 1.0]")]

        assert_equal(self.task.get_from_database('Test_1'), 1.0)
        assert_equal(self.task.get_from_database('Test_2'), 1.0)

        self.task.definitions = []

        aux = self.task.accessible_database_entries()
        assert_not_in('Test_1', aux)
        assert_not_in('Test_2', aux)

    def test_check1(self):
        # Simply test that everything is ok if defintion are corrects.
        self.task.definitions = [('1', '2.0'), ('2', "['a', 1.0]")]

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)
        assert_equal(self.task.get_from_database('Test_1'), 2.0)
        assert_equal(self.task.get_from_database('Test_2'), ['a', 1.0])

    def test_check2(self):
        # Test handling a wrong definition.
        self.task.definitions = [('1', '2.0'), ('2', "*['a', 1.0]")]

        test, traceback = self.task.check()
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test-2', traceback)
        assert_equal(self.task.get_from_database('Test_1'), 2.0)
        assert_equal(self.task.get_from_database('Test_2'), 1.0)

    def test_perform(self):
        # Test performing.
        self.root.task_database.prepare_for_running()

        self.task.perform()
コード例 #3
0
class TestDefinitionTask(object):
    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = DefinitionTask(task_name='Test')
        self.root.children_task.append(self.task)

    def test_definitions_observation(self):
        # Test that the database is correctly updated when defs change.
        self.task.definitions = [('1', '2.0'), ('2', "['a', 1.0]")]

        assert_equal(self.task.get_from_database('Test_1'), 1.0)
        assert_equal(self.task.get_from_database('Test_2'), 1.0)

        self.task.definitions = []

        aux = self.task.accessible_database_entries()
        assert_not_in('Test_1', aux)
        assert_not_in('Test_2', aux)

    def test_check1(self):
        # Simply test that everything is ok if defintion are corrects.
        self.task.definitions = [('1', '2.0'), ('2', "['a', 1.0]")]

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)
        assert_equal(self.task.get_from_database('Test_1'), 2.0)
        assert_equal(self.task.get_from_database('Test_2'), ['a', 1.0])

    def test_check2(self):
        # Test handling a wrong definition.
        self.task.definitions = [('1', '2.0'), ('2', "*['a', 1.0]")]

        test, traceback = self.task.check()
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test-2', traceback)
        assert_equal(self.task.get_from_database('Test_1'), 2.0)
        assert_equal(self.task.get_from_database('Test_2'), 1.0)

    def test_perform(self):
        # Test performing.
        self.root.task_database.prepare_for_running()

        self.task.perform()
コード例 #4
0
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = DefinitionTask(task_name='Test')
     self.root.children_task.append(self.task)
コード例 #5
0
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = DefinitionTask(task_name='Test')
     self.root.children_task.append(self.task)