Exemplo n.º 1
0
 def test_no_double_invoke(self):
     runlist = []
     t1 = Task('t1', action=lambda t: runlist.append(t.name))
     t2 = Task('t2', depends=[t1], action=lambda t: runlist.append(t.name))
     t3 = Task('t3', depends=[t2, t1], action=lambda t: runlist.append(t.name))
     self.manage.add(t1)
     self.manage.add(t2)
     self.manage.add(t3)
     self.manage.invoke('t3')
     self.assertEqual(['t1', 't2', 't3'], runlist)
Exemplo n.º 2
0
    def test_invoke_with_circular_dependencies(self):
        runlist = []
        t1 = Task('t1')
        t2 = Task('t2', depends=[t1])
        t1.depends = [t2]
        self.manage.add(t1)
        self.manage.add(t2)

        with self.assertRaises(RuntimeError):
            self.manage.invoke('t1')
Exemplo n.º 3
0
 def test_invoke(self):
     runlist = []
     t1 = Task('t1', action=lambda t: runlist.append(t.name))
     t2 = Task('t2', action=lambda t: runlist.append(t.name))
     self.manage.add(t1)
     self.manage.add(t2)
     self.manage.add(Task('t3', depends=[t1, t2],
                     action = lambda t: runlist.append(t.name)))
     self.manage.invoke('t3')
     self.assertEqual(runlist, ['t1', 't2', 't3'])
Exemplo n.º 4
0
    def test_call(self):
        self.flag = True
        def func(task):
            self.flag = False

        t1 = Task("t1", action=func)
        self.assertEquals(True, self.flag)
        t1()
        self.assertEquals(False, self.flag)
Exemplo n.º 5
0
 def test_create(self):
     t = Task("t")
     self.assertEquals("t", t.name)
     self.assertEquals([], t.depends)
     self.assertEquals(empty, t.action)
     self.assertTrue(t.needed())
Exemplo n.º 6
0
 def test_repr(self):
     t1 = Task("t1")
     t2 = Task("t2")
     t = Task("t", [t1, t2])
     self.assertEquals('<Task t => [t1,t2]>', str(t))
Exemplo n.º 7
0
 def test_remove(self):
     name = 'I will be remove'
     self.manage.add(Task(name))
     self.manage.remove(name)
     with self.assertRaises(TaskNotFound):
         self.manage.find(name)
Exemplo n.º 8
0
 def test_add_duplication(self):
     with self.assertRaises(DuplicatedTaskName) as context:
         name = 'duplicate name'
         self.manage.add(Task(name))
         self.manage.add(Task(name))