예제 #1
0
    def testGetTotalRemainingTime(self):
        """Tests the current remaining time of a given sprint"""
        def compute_remaining_time(backlog):
            total_rt = 0
            for bi in backlog:
                if bi[Key.TYPE] == Type.TASK:
                    total_rt += int(bi[Key.REMAINING_TIME] or 0)
            return total_rt

        def set_rtusp_ratio(sprint):
            metrics = TeamMetrics(self.env, sprint, sprint.team)
            metrics[Key.RT_USP_RATIO] = 2  # 16h for 8 usp
            metrics.save()

        def remove_link_to_tasks_from_one_story(backlog):
            rt_delta = 0
            for bi in backlog:
                if bi[Key.TYPE] == Type.USER_STORY:
                    story = bi.ticket
                    if len(story.get_outgoing()) > 0:
                        # When we remoev all tasks, we need to use the estimated
                        # remaining time for this story
                        estimated_remaining_time = int(
                            story[Key.ESTIMATED_REMAINING_TIME] or 0)
                        rt_delta += estimated_remaining_time
                    for task in story.get_outgoing():
                        story.del_link_to(task)
                        # We don't add the task's remaining time to rt_delta
                        # because we assume that this task was counted before.
                        # When a task becomes an orphan task, the total remaining
                        # time changes only because of the story.
                    break
            return rt_delta

        sprint = self.create_sprint_with_team('RemTimeSprint')
        backlog = self.build_sprint_backlog(sprint)
        total_rt = compute_remaining_time(backlog)
        cmd_total_rt = SprintController.GetTotalRemainingTimeCommand(
            self.env, sprint=sprint.name)
        total = self.controller.process_command(cmd_total_rt)
        self.assert_equals(total_rt, total)
        set_rtusp_ratio(sprint)
        total_rt += remove_link_to_tasks_from_one_story(backlog)
        total = self.controller.process_command(cmd_total_rt)
        self.assert_equals(total_rt, total)
예제 #2
0
    def testRemainingTimeMustIncludeTasksBelowBugs(self):
        """If bugs are allowed in a sprint backlog, all tasks below a bug must
        count for the remaining time."""
        sprint = self.create_sprint_with_team('RemTimeSprint')
        backlog = self.teh.create_backlog(
            'StatsBacklog',
            20,
            1,
            ticket_types=[Type.USER_STORY, Type.TASK],
            scope=sprint.name)
        self.assert_equals(20, len(backlog))
        # Now check how many tasks are in there
        total_rt = total_sp = 0
        for bi in backlog:
            if bi[Key.TYPE] == Type.TASK:
                total_rt += int(bi[Key.REMAINING_TIME] or 0)
            else:
                total_sp += int(bi[Key.STORY_POINTS] or 0)
        cmd_total_rt = SprintController.GetTotalRemainingTimeCommand(
            self.env, sprint=sprint.name)
        remaining_time_before_bug = self.controller.process_command(
            cmd_total_rt)
        self.assert_equals(total_rt, remaining_time_before_bug)

        bug = self.teh.create_ticket(Type.BUG, {Key.SPRINT: sprint.name})
        bug_task = self.teh.create_ticket(Type.TASK, {
            Key.SPRINT: sprint.name,
            Key.REMAINING_TIME: "7"
        })
        self.assert_true(bug.link_to(bug_task))

        remaining_time_after_bug = self.controller.process_command(
            cmd_total_rt)

        self.assert_equals(remaining_time_before_bug + 7,
                           remaining_time_after_bug)