def testTicketByTypeCountInProgressTicketsCorrectly(self): sprint = self.teh.create_sprint('FooSprint') task = self.teh.create_task(sprint=sprint.name) self._set_status_for_ticket(Status.ACCEPTED, task) cmd_stats = SprintController.GetTicketsStatisticsCommand(self.env, sprint=sprint, totals=False) stats_by_type = self.controller.process_command(cmd_stats) self.assert_equals({Type.TASK: (0, 1, 0)}, stats_by_type)
def testSprintTicketsStatistics(self): # create some tickets statistics... sprint = self.teh.create_sprint('StatsSprint') backlog = self.teh.create_backlog( 'StatsBacklog', 20, 1, ticket_types=[Type.USER_STORY, Type.TASK], scope=sprint.name) self.assert_equals(20, len(backlog)) real_stats = {} for bi in backlog: t_type = bi[Key.TYPE] if t_type not in real_stats: real_stats[t_type] = (0, 0, 0) planned, in_progress, closed = real_stats[t_type] if bi[Key.STATUS] == Status.CLOSED: closed += 1 else: planned += 1 real_stats[t_type] = (planned, in_progress, closed) # now make some stats, should be all open cmd_stats = SprintController.GetTicketsStatisticsCommand( self.env, sprint=sprint.name) tickets = self.controller.process_command(cmd_stats) for t_type, stats in tickets.items(): self.assert_equals(real_stats[t_type], tuple(stats)) # now try to get global statistics, only the totals planned = reduce(lambda x, y: x + y, [p[0] for p in real_stats.values()], 0) closed = reduce(lambda x, y: x + y, [p[1] for p in real_stats.values()], 0) cmd_stats.totals = True totals = self.controller.process_command(cmd_stats) self.assert_equals(planned, totals[0]) self.assert_equals(closed, totals[1])