def testTaskCleanup(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myTask1.1"
        myTask1.configId = "myTask1"

        myTask2 = BasicTestTask()
        myTask2.name = "myTask1.2"
        myTask2.configId = "myTask1"
        myTask2.state = "DOING_SOMETHING" # keep this task from being cleaned

        scheduler = Scheduler()
        scheduler.addTask(myTask1)
        scheduler.addTask(myTask2)

        self.assertTrue(scheduler._isTaskCleanable(myTask1))
        self.assertFalse(scheduler._isTaskCleanable(myTask2))

        # call cleanupTasks directly so we don't have to wait for a
        # looping call to start it
        self.assertFalse(myTask1.cleaned)
        self.assertFalse(myTask2.cleaned)
        scheduler.removeTasksForConfig(myTask1.configId)
        scheduler._cleanupTasks()
        self.assertTrue(myTask1.cleaned)
        self.assertFalse(myTask2.cleaned)
    def testDeleteTasks(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myDevice:myTask1"
        myTask1.configId = "myDevice"

        myTask2 = BasicTestTask()
        myTask2.name = "myDevice:myTask2"
        myTask2.configId = "myDevice"

        myTask3 = BasicTestTask()
        myTask3.name = "myDevice2:myTask3"
        myTask3.configId = "myDevice2"

        scheduler = Scheduler()
        scheduler.addTask(myTask1)
        scheduler.addTask(myTask2)
        scheduler.addTask(myTask3)
        self.assertEquals(len(scheduler._tasks), 3)
        self.assertTrue(myTask1.name in scheduler._tasks)
        self.assertTrue(myTask2.name in scheduler._tasks)
        self.assertTrue(myTask3.name in scheduler._tasks)

        scheduler.removeTasksForConfig("myDevice")
        self.assertEquals(len(scheduler._tasks), 1)
        self.assertFalse(myTask1.name in scheduler._tasks)
        self.assertFalse(myTask2.name in scheduler._tasks)
        self.assertTrue(myTask3.name in scheduler._tasks)
Exemplo n.º 3
0
    def testTaskCleanup(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myTask1.1"
        myTask1.configId = "myTask1"

        myTask2 = BasicTestTask()
        myTask2.name = "myTask1.2"
        myTask2.configId = "myTask1"
        myTask2.state = "DOING_SOMETHING"  # keep this task from being cleaned

        scheduler = Scheduler()
        scheduler.addTask(myTask1)
        scheduler.addTask(myTask2)

        self.assertTrue(scheduler._isTaskCleanable(myTask1))
        self.assertFalse(scheduler._isTaskCleanable(myTask2))

        # call cleanupTasks directly so we don't have to wait for a
        # looping call to start it
        self.assertFalse(myTask1.cleaned)
        self.assertFalse(myTask2.cleaned)
        scheduler.removeTasksForConfig(myTask1.configId)
        scheduler._cleanupTasks()
        self.assertTrue(myTask1.cleaned)
        self.assertFalse(myTask2.cleaned)
Exemplo n.º 4
0
    def testDeleteTasks(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myDevice:myTask1"
        myTask1.configId = "myDevice"

        myTask2 = BasicTestTask()
        myTask2.name = "myDevice:myTask2"
        myTask2.configId = "myDevice"

        myTask3 = BasicTestTask()
        myTask3.name = "myDevice2:myTask3"
        myTask3.configId = "myDevice2"

        scheduler = Scheduler()
        scheduler.addTask(myTask1)
        scheduler.addTask(myTask2)
        scheduler.addTask(myTask3)
        self.assertEquals(len(scheduler._tasks), 3)
        self.assertTrue(myTask1.name in scheduler._tasks)
        self.assertTrue(myTask2.name in scheduler._tasks)
        self.assertTrue(myTask3.name in scheduler._tasks)

        scheduler.removeTasksForConfig("myDevice")
        self.assertEquals(len(scheduler._tasks), 1)
        self.assertFalse(myTask1.name in scheduler._tasks)
        self.assertFalse(myTask2.name in scheduler._tasks)
        self.assertTrue(myTask3.name in scheduler._tasks)
    def testTaskDoneCallback(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myTask1"
        myTask1.configId = "myTask1"

        called = False
        def myCallback(taskName):
            self.assertEquals(taskName, myTask1.name)
            called = True

        scheduler = Scheduler()
        scheduler.addTask(myTask1, myCallback)
Exemplo n.º 6
0
    def testTaskDoneCallback(self):
        myTask1 = BasicTestTask()
        myTask1.name = "myTask1"
        myTask1.configId = "myTask1"

        called = False

        def myCallback(taskName):
            self.assertEquals(taskName, myTask1.name)
            called = True

        scheduler = Scheduler()
        scheduler.addTask(myTask1, myCallback)