def testDone(self):
        """Test the done methods of the task.

    The done method should return false is the task has not perform and return
    true after the task is finished.
    """

        flags = range(NUM_FLAGS)

        flag_sets = [MockFlagSet(flag) for flag in flags]
        for flag_set in flag_sets:
            work_task = Task(flag_set)

            # The task has not been compiled nor tested.
            assert not work_task.Done(task.TEST_STAGE)
            assert not work_task.Done(task.BUILD_STAGE)

            # After the task has been compiled, it should indicate finished in BUILD
            # stage.
            result = tuple(
                [random.randint(0, RANDOM_BUILD_RESULT) for _ in range(5)])
            work_task.SetResult(task.BUILD_STAGE, result)
            assert not work_task.Done(task.TEST_STAGE)
            assert work_task.Done(task.BUILD_STAGE)

            # After the task has been tested, it should indicate finished in TEST
            # stage.
            work_task.SetResult(task.TEST_STAGE,
                                random.randint(0, RANDOM_TESTRESULT))
            assert work_task.Done(task.TEST_STAGE)
            assert work_task.Done(task.BUILD_STAGE)
    def testGetSetResult(self):
        """Test the get and set result methods of the task.

    The get result method should return the same results as were set.
    """

        flag_sets = [MockFlagSet(flag) for flag in range(NUM_FLAGS)]
        for flag_set in flag_sets:
            result_task = Task(flag_set)

            # The get result method should return the same results as were set, in
            # build stage. Currently, the build result is a 5-element tuple containing
            # the checksum of the result image, the performance cost of the build, the
            # compilation image, the length of the build, and the length of the text
            # section of the build.
            result = tuple(
                [random.randint(0, RANDOM_BUILD_RESULT) for _ in range(5)])
            result_task.SetResult(task.BUILD_STAGE, result)
            assert result == result_task.GetResult(task.BUILD_STAGE)

            # The checksum is the identifier of the test stage.
            identifier = result_task.GetIdentifier(task.TEST_STAGE)
            # The first element of the result tuple is the checksum.
            assert identifier == result[0]

            # The get result method should return the same results as were set, in
            # test stage.
            random_test_result = random.randint(0, RANDOM_TESTRESULT)
            result_task.SetResult(task.TEST_STAGE, random_test_result)
            test_result = result_task.GetResult(task.TEST_STAGE)
            assert test_result == random_test_result