Ejemplo n.º 1
0
    def __init__(self, msg=None):
        TaskContainer.__init__(self, msg)

        # add some children
        self.add_task(StandaloneTask("child 1"))
        self.add_task(StandaloneTask("child 2"))
        self.add_task(StandaloneTask("child 3"))
Ejemplo n.º 2
0
    def test_status_all_subtask_complete(self):
        """
        Tests for TaskContainer that has all complete subtasks
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1)
        ctask.add_task(task2)

        self.verify_status(STATUS_COMPLETE, STATUS_COMPLETE, STATUS_COMPLETE, ctask)
Ejemplo n.º 3
0
    def test_status_not_started(self):
        """
        Test status for container task that has no started subtasks
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1)
        ctask.add_task(task2)

        self.verify_status(STATUS_STOPPED, STATUS_STOPPED, STATUS_STOPPED, ctask)
Ejemplo n.º 4
0
    def test_sequential_work(self):
        """
        Tests for verifying TaskContainer iterates through subtasks correctly 
        when run in sequential mode
        """
        task1 = StartupAndWaitTask()
        task2 = StartupAndWaitTask()

        ctask = TaskContainer("tester")
        ctask.parent = WorkerProxy()
        ctask.add_task(task1)
        ctask.add_task(task2)
        return threads.deferToThread(self.verify_sequential_work, task=ctask)
Ejemplo n.º 5
0
    def test_progress_auto_weighting(self):
        """
        Tests TaskContainer.progress() with auto weighting on all subtasks
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1)
        ctask.add_task(task2)

        self.assertEqual(ctask.progress(), 0, "Both task progresses are zero, container progress should be zero")

        task1.value = 50
        self.assertEqual(
            ctask.progress(), 25, "Values are [50,0] with auto weighting, container progress should be 25%"
        )

        task1.value = 100
        self.assertEqual(
            ctask.progress(), 50, "Values are [100,0] with auto weighting, container progress should be 50%"
        )

        task2.value = 50
        self.assertEqual(
            ctask.progress(), 75, "Values are [100,50] with auto weighting, container progress should be 75%"
        )

        task2.value = 100
        self.assertEqual(
            ctask.progress(), 100, "Values are [100,100] with auto weighting, container progress should be 100%"
        )
Ejemplo n.º 6
0
    def test_progress_when_status_is_completed(self):
        """
        Tests TaskContainer.progress when the tasks have STATUS_COMPLETE
        set as their status
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        task1._status = STATUS_COMPLETE
        task2._status = STATUS_COMPLETE

        ctask = TaskContainer("tester")
        ctask.add_task(task1)
        ctask.add_task(task2)

        self.assertEqual(ctask.progress(), 100, "Container task should report 100 because status is STATUS_COMPLETE")
Ejemplo n.º 7
0
    def test_status_any_subtask_paused(self):
        """
        Tests for TaskContainer that has any paused subtasks
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1)
        ctask.add_task(task2)

        self.verify_status(STATUS_PAUSED, STATUS_STOPPED, STATUS_PAUSED, ctask)
        self.verify_status(STATUS_STOPPED, STATUS_PAUSED, STATUS_PAUSED, ctask)

        self.verify_status(STATUS_COMPLETE, STATUS_PAUSED, STATUS_PAUSED, ctask)
        self.verify_status(STATUS_PAUSED, STATUS_COMPLETE, STATUS_PAUSED, ctask)

        self.verify_status(STATUS_PAUSED, STATUS_RUNNING, STATUS_RUNNING, ctask)
        self.verify_status(STATUS_RUNNING, STATUS_PAUSED, STATUS_RUNNING, ctask)
Ejemplo n.º 8
0
    def test_progress_with_one_weighted(self):
        """
        Tests TaskContainer.progress() with manual weighting on only 1 subtask
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1, 80)
        ctask.add_task(task2)

        self.assertEqual(ctask.progress(), 0, "Both task progresses are zero, container progress should be zero")

        task1.value = 50
        self.assertEqual(
            ctask.progress(),
            40,
            "Values are [50,0] with manual weighting 80% on task 1, container progress should be 40%",
        )

        task1.value = 100
        self.assertEqual(
            ctask.progress(),
            80,
            "Values are [100,0] with manual weighting 80% on task 1, container progress should be 80%",
        )

        task2.value = 50
        self.assertEqual(
            ctask.progress(),
            90,
            "Values are [100,50] with manual weighting 80% on task 1, container progress should be 90%",
        )

        task2.value = 100
        self.assertEqual(
            ctask.progress(),
            100,
            "Values are [100,100] with manual weighting 80% on task 1, container progress should be 100%",
        )
Ejemplo n.º 9
0
    def test_progress_with_one_weighted_multiple_auto(self):
        """
        Tests TaskContainer.progress() with manual weighting on only 1 subtask
        and multiple subtasks with automatic rating
        """
        task1 = StatusSimulatingTaskProxy()
        task2 = StatusSimulatingTaskProxy()
        task3 = StatusSimulatingTaskProxy()

        ctask = TaskContainer("tester")
        ctask.add_task(task1, 80)
        ctask.add_task(task2)  # should default to 10% of the overall progress
        ctask.add_task(task3)  # should default to 10% of the overall progress

        self.assertEqual(ctask.progress(), 0, "Both task progresses are zero, container progress should be zero")

        task1.value = 50
        self.assertEqual(
            ctask.progress(),
            40,
            "Values are [50,0,0] with manual weighting 80% on task 1, container progress should be 40%",
        )

        task1.value = 100
        self.assertEqual(
            ctask.progress(),
            80,
            "Values are [100,0,0] with manual weighting 80% on task 1, container progress should be 80%",
        )

        task2.value = 50
        self.assertEqual(
            ctask.progress(),
            85,
            "Values are [100,50,0] with manual weighting 80% on task 1, container progress should be 85%",
        )

        task2.value = 100
        self.assertEqual(
            ctask.progress(),
            90,
            "Values are [100,100,0] with manual weighting 80% on task 1, container progress should be 90%",
        )

        task3.value = 50
        self.assertEqual(
            ctask.progress(),
            95,
            "Values are [100,100,50] with manual weighting 80% on task 1, container progress should be 95%",
        )

        task3.value = 100
        self.assertEqual(
            ctask.progress(),
            100,
            "Values are [100,100,100] with manual weighting 80% on task 1, container progress should be 100%",
        )