def get(self, request, *args, **kwargs): new_sprint = Sprint(project=Project.objects.get(name_short=self.kwargs.get('project'))) new_sprint.save() s = new_sprint.seqnum return redirect(reverse('backlog:backlog', kwargs={'project': self.kwargs.get('project'), 'sqn_s': s }))
def post(self, request, *args, **kwargs): proj = Project.objects.get(name_short=self.kwargs.get('project')) sprint = Sprint.objects.filter(project__name_short=self.kwargs.get('project')) \ .get(seqnum=self.kwargs.get('sqn_s')) sprint.set_inactive() signals.stop.send(sender=sprint.__class__, instance=sprint, user=self.request.user) new_sprint = request.POST.get('sprint') if not new_sprint: return redirect(reverse('backlog:backlog', kwargs={'project': self.kwargs.get('project')})) selection = request.POST.getlist('move_to_new_sprint') sprint = None if new_sprint == 'new': if selection: sprint = Sprint(project=proj) sprint.save() else: sprint = get_r_object_or_404(self.request.user, Sprint, project=proj, seqnum=new_sprint) for issue in proj.issue.filter(number__in=selection): issue.sprint = sprint issue.save() if selection: return redirect(reverse('backlog:backlog', kwargs={'project': self.kwargs.get('project'), 'sqn_s': sprint.seqnum })) return redirect(reverse('backlog:backlog', kwargs={'project': self.kwargs.get('project')}))
def setUp(self): self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.developer.add(self.user) # TODO hopefully this will correctly create this sprint as already completed. self.sprint = Sprint(project=self.project, seqnum=3, startdate='2016-03-04', enddate='2016-03-05') self.sprint.save() self.client.force_login(self.user)
def setUp(self): self.client.force_login(self.user) # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData() self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.manager.add(self.user) self.sprint = Sprint(project=self.project) self.sprint.save()
def setUp(self): # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData() self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.developer.add(self.user) # TODO hopefully this will correctly create this sprint as already completed. self.sprint = Sprint(project=self.project, seqnum=3, startdate='2016-03-04', enddate='2016-03-05') self.sprint.save() self.client.force_login(self.user)
def setUp(self): self.client.force_login(self.user) # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData() self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.manager.add(self.user) self.sprint = Sprint(project=self.project) self.sprint.save()
def test_dont_assign_issues_to_stoped_sprints(self): issue = Issue(title="Test-Issue", project=self.project, type="Bug") issue.save() issue2 = Issue(title="Test-Issue2", project=self.project, type="Bug") issue2.save() # start sprint self.sprint.set_active() self.sprint.save() self.project.currentsprint = self.sprint self.project.save() # assign first issue response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) # first issue is part of the sprint issue.refresh_from_db() self.assertIsNotNone(issue.sprint) # stop sprint response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': []}, follow=True) self.assertEqual(Issue.objects.get(pk=issue.pk).was_in_sprint, True) # assign second issue => should fail response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue2.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short})) # second issue is NOT part of the sprint issue2.refresh_from_db() self.assertIsNone(issue2.sprint) # create new sprint - so we don't run into the not-sprint part but really into the atomic check for enddate sprint2 = Sprint(project=self.project) sprint2.save() response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue2.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) issue2.refresh_from_db() self.assertIsNone(issue2.sprint)
def test_managerfunctions(self): issue1 = Issue(title="issue1", project=self.project, kanbancol=self.column) issue1.save() sprint_current = Sprint(project=self.project, startdate=(timezone.now() - timedelta(days=1))) sprint_current.save() sprint_old = Sprint(project=self.project, startdate=(timezone.now() - timedelta(days=14)), enddate=(timezone.now() - timedelta(days=1))) sprint_old.save() issues_wo_sprint = Issue.objects.without_sprint() self.assertTrue(issue1 in issues_wo_sprint) issue1.sprint = sprint_current issue1.save() issues_cur_sprint = Issue.objects.current_sprint() self.assertTrue(issue1 in issues_cur_sprint) issue1.sprint = sprint_old issue1.save() issues_cur_sprint = Issue.objects.current_sprint() issues_wo_sprint = Issue.objects.without_sprint() self.assertFalse(issue1 in issues_cur_sprint) self.assertFalse(issue1 in issues_wo_sprint)
def genrate_sprint(pbs, sprint_length, end_date): start_date = pbs.start_date i = 1 while start_date < pbs.ETA: s1 = Sprint() s1.start_date = start_date s1.end_date = start_date + timedelta(sprint_length) s1.project_backlog = pbs s1.name = pbs.projectBacklogSetting.sprint_template + str(i) i += 1 s1.save() start_date = s1.end_date + timedelta(1) add_data_to_project()
def setUpTestData(cls): # NOTE: if you modify these elements they need to be created in setUp(), instead of here cls.user = get_user_model().objects.create_user('username', 'b', 'c') cls.user2 = get_user_model().objects.create_user('user2', 'x', 'y') cls.project = Project(creator=cls.user, name_short=cls.short) cls.project.save() cls.project.developer.set((cls.user.pk, cls.user2.pk)) cls.project.manager.set((cls.user.pk, )) cls.project.save() cls.issue = Issue() cls.issue.title = "sometitle" cls.issue.project = cls.project cls.issue.save() cls.issue.assignee.add(cls.user) cls.issue.save() cls.issue2 = Issue() cls.issue2.title = "othertitle" cls.issue2.project = cls.project cls.issue2.description = "foo" cls.issue2.save() cls.issue2.assignee.set([cls.user, cls.user2]) cls.issue2.save() cls.sprint = Sprint(project=cls.project) cls.sprint.save()
def test_olea_frontend(self): self.client.force_login(self.user) self.project.refresh_from_db() # test creating issue without sprint values = { 'expression': 'Task from frontend @a', 'currentsprint': '', 'next': reverse('backlog:backlog', kwargs={'project': self.project.name_short}), } response = self.client.post( reverse('olea:processOlea', kwargs={'project': self.project.name_short}), values) self.assertRedirects(response, values['next']) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertNotIn('oleaexpression', self.client.session) self.assertNotIn('oleafocus', self.client.session) self.assertEqual( Issue.objects.filter(project=self.project, title="Task from frontend", assignee=self.user).count(), 1) issue = Issue.objects.get(project=self.project, title="Task from frontend") self.assertEqual(issue.sprint, None) self.assertEqual(issue.number, 1) self.project.refresh_from_db() self.assertEqual(self.project.issue.count(), 1) self.assertEqual(self.project.nextTicketId, 2) # test creation with sprint sprint = Sprint(project=self.project) sprint.save() sprint2 = Sprint(project=self.project) sprint2.save() values['currentsprint'] = sprint.seqnum values['expression'] = 'Another frontend task @a' response = self.client.post( reverse('olea:processOlea', kwargs={'project': self.project.name_short}), values) self.assertNotIn('oleaexpression', self.client.session) self.assertIn('oleafocus', self.client.session) self.assertEqual(self.client.session['oleafocus'], 'autofocus') self.assertRedirects(response, values['next']) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertEqual( Issue.objects.filter(project=self.project, title="Another frontend task", assignee=self.user).count(), 1) issue = Issue.objects.get(project=self.project, title="Another frontend task") self.project.refresh_from_db() self.assertEqual(self.project.issue.count(), 2) self.assertEqual(issue.sprint, sprint) self.assertEqual(issue.number, 2) # test editing issue with currentsprint set (should not change sprint) issue = Issue.objects.get(project__name_short="PRJ", number=1) self.assertEqual(issue.sprint, None) values['expression'] = '>PRJ-1 @a' response = self.client.post( reverse('olea:processOlea', kwargs={'project': self.project.name_short}), values) self.assertIn('oleafocus', self.client.session) self.assertEqual(self.client.session['oleafocus'], 'autofocus') self.assertRedirects(response, values['next']) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertNotIn('oleafocus', self.client.session) issue.refresh_from_db() self.assertEqual(issue.sprint, None) # set sprint for issue and try again issue.sprint = sprint2 issue.save() values['expression'] = '>PRJ-1 @a' response = self.client.post( reverse('olea:processOlea', kwargs={'project': self.project.name_short}), values) self.assertIn('oleafocus', self.client.session) self.assertEqual(self.client.session['oleafocus'], 'autofocus') self.assertRedirects(response, values['next']) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertNotIn(values['expression'], response.content.decode()) self.assertNotIn('oleafocus', self.client.session) issue.refresh_from_db() self.assertEqual(issue.sprint, sprint2) # check that syntax errors are signalled by message values['expression'] = '>PRJ-1:! @a' response = self.client.post(reverse( 'olea:processOlea', kwargs={'project': self.project.name_short}), values, follow=True) self.assertIn('>PRJ-1:! @a', response.content.decode()) self.assertRedirects(response, values['next']) self.assertEqual(len(list(response.context['messages'])), 1) self.assertEqual(response.status_code, 200) self.assertNotIn('oleaexpression', self.client.session) self.assertNotIn('oleafocus', self.client.session) # supply invalid sprint id values['expression'] = 'This is actually correct @a' values['currentsprint'] = '42' response = self.client.post(reverse( 'olea:processOlea', kwargs={'project': self.project.name_short}), values, follow=True) self.assertRedirects(response, values['next']) self.assertIn(values['expression'], response.content.decode()) self.assertNotIn('oleafocus', self.client.session) self.assertEqual(len(list(response.context['messages'])), 1) self.assertEqual(response.status_code, 200) issue = Issue.objects.get(project=self.project, title="This is actually correct") self.assertEqual(issue.sprint, None)
def test_sprints_and_issues_in_archive_view(self): newsprint = Sprint(project=self.project) newsprint.save() startedsprint = Sprint(project=self.project, startdate=datetime.datetime.now()) startedsprint.save() stoppedsprint = Sprint(project=self.project, startdate=datetime.datetime.now(), enddate=datetime.datetime.now()) stoppedsprint.save() wrongsprint = Sprint(project=self.project, enddate=datetime.datetime.now()) wrongsprint.save() issueinnew = Issue(title="boo", project=self.project, sprint=newsprint, archived=True) issueinnew.save() issueinstarted = Issue(title="coo", project=self.project, sprint=startedsprint, archived=True) issueinstarted.save() issueinstopped = Issue(title="doo", project=self.project, sprint=stoppedsprint, archived=True) issueinstopped.save() issueinwrong = Issue(title="foo", project=self.project, sprint=wrongsprint, archived=True) issueinwrong.save() issueinno = Issue(title="goo", project=self.project, archived=True) issueinno.save() response = self.client.get( reverse('archive:archive', kwargs={'project': self.project.name_short})) self.assertNotIn(issueinnew, response.context['archived_issues_without_sprint']) self.assertNotIn(issueinwrong, response.context['archived_issues_without_sprint']) self.assertNotIn(issueinstopped, response.context['archived_issues_without_sprint']) self.assertNotIn(issueinstarted, response.context['archived_issues_without_sprint']) self.assertIn(issueinno, response.context['archived_issues_without_sprint']) self.assertEqual(response.context['sprints_sorted'].all()[0], wrongsprint) self.assertEqual(response.context['sprints_sorted'].all()[1], stoppedsprint) self.assertEqual(response.context['sprints_sorted'].all()[2], startedsprint) self.assertEqual(response.context['sprints_sorted'].all()[3], newsprint)
def test_issue_properties(self): issues = self.create_some_issues() # archived issue is not in context response = self.client.get(reverse('issue:issue_list_all_view')) self.assertIn(issues[0], response.context['issues'].object_list) self.assertNotIn(issues[3], response.context['issues'].object_list) # done issue is not in context response = self.client.get(reverse('issue:issue_list_all_view')) self.assertNotIn(issues[2], response.context['issues'].object_list) # archived/done issue is not in context, done issue is in context response = self.client.get(reverse('issue:issue_list_all_view')) self.assertIn(issues[0], response.context['issues'].object_list) self.assertIn(issues[1], response.context['issues'].object_list) self.assertIn(issues[4], response.context['issues'].object_list) self.assertNotIn(issues[3], response.context['issues'].object_list) self.assertNotIn(issues[2], response.context['issues'].object_list) # filter project response = self.client.get(reverse('issue:issue_list_all_view')+'?show_done=false'+'&project=PRJ') # issue from second project not in context self.assertNotIn(issues[4], response.context['issues'].object_list) # not done issues from first project in context self.assertEqual(2, len(response.context['issues'].object_list)) # filter not existing project response = self.client.get(reverse('issue:issue_list_all_view')+'?show_done=false'+'&project=PRJ2') self.assertIn(issues[4], response.context['issues'].object_list) self.assertEqual(3, len(response.context['issues'].object_list)) # filter in running sprint sprint = Sprint(project=self.project) sprint.save() issues[0].sprint = sprint issues[0].save() response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&project=PRJ&sprint_only=true') self.assertEqual(0, len(response.context['issues'].object_list)) sprint.set_active() response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&project=PRJ&sprint_only=true') self.assertEqual(1, len(response.context['issues'].object_list)) self.assertIn(issues[0], response.context['issues'].object_list) sprint.set_inactive() response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&project=PRJ&sprint_only=true') self.assertEqual(0, len(response.context['issues'].object_list)) # order_by title response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=title' + '&project=PRJ') self.assertEqual(issues[0], response.context['issues'].object_list.pop(0)) response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=title' + '&project=PRJ&reverse=true') self.assertEqual(issues[2], response.context['issues'].object_list.pop(0)) # order_by priority response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=priority&reverse=false') self.assertEqual(issues[4], response.context['issues'].object_list.pop(0)) response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=priority&reverse=true') self.assertEqual(issues[0], response.context['issues'].object_list.pop(0)) # order_by type response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=type&project=PRJ&reverse=false') self.assertEqual(3, len(response.context['issues'].object_list)) self.assertEqual(issues[0], response.context['issues'].object_list.pop(0)) self.assertEqual(issues[2], response.context['issues'].object_list.pop(1)) response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=type&reverse=true&project=PRJ') self.assertEqual(3, len(response.context['issues'].object_list)) self.assertEqual(issues[2], response.context['issues'].object_list.pop(0)) self.assertEqual(issues[0], response.context['issues'].object_list.pop(1)) # order_by status response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=status&project=PRJ') self.assertEqual(3, len(response.context['issues'].object_list)) self.assertEqual(issues[0], response.context['issues'].object_list.pop(0)) self.assertEqual(issues[2], response.context['issues'].object_list.pop(1)) response = self.client.get(reverse('issue:issue_list_all_view') + '?show_done=true' + '&order_by=status&reverse=true&project=PRJ') self.assertEqual(3, len(response.context['issues'].object_list)) self.assertEqual(issues[0], response.context['issues'].object_list.pop(0)) self.assertEqual(issues[2], response.context['issues'].object_list.pop(1)) # test pagination PageNotInteger exception response = self.client.get(reverse('issue:issue_list_all_view') + '?page=asd' + '&show_done=true', follow=True) self.assertEqual(4, len(response.context['issues'].object_list)) # test pagination EmptyPage exception response = self.client.get(reverse('issue:issue_list_all_view') + '?page=5' + '&show_done=true', follow=True) self.assertEqual(4, len(response.context['issues'].object_list))
class BacklogTest(TestCase): @classmethod def setUpTestData(cls): # NOTE: if you modify this element it needs to be created in setUp, instead of here cls.user = get_user_model().objects.create_user('django', '*****@*****.**', 'unchained') def setUp(self): self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.developer.add(self.user) # TODO hopefully this will correctly create this sprint as already completed. self.sprint = Sprint(project=self.project, seqnum=3, startdate='2016-03-04', enddate='2016-03-05') self.sprint.save() self.client.force_login(self.user) def test_view_and_template(self): # general backlog view_and_template(self, BacklogListView, 'backlog/backlog_list.html', 'backlog:backlog', address_kwargs={'project': self.project.name_short}) # backlog for specific sprint view_and_template(self, BacklogListView, 'backlog/backlog_list.html', 'backlog:backlog', address_kwargs={'project': self.project.name_short, 'sqn_s': 3}) def test_redirect_to_login_and_login_required(self): self.client.logout() # general backlog redirect_to_login_and_login_required(self, 'backlog:backlog', address_kwargs={'project': self.project.name_short}) # backlog for specific sprint redirect_to_login_and_login_required(self, 'backlog:backlog', address_kwargs={'project': self.project.name_short, 'sqn_s': 3}) def test_backlog_list(self): # TODO TESTCASE # TODO see sprint/testcases/test_sprint.py for already existing tests # and move them if there are only-backlog-tests pass def test_list_current_sprint(self): # TODO TESTCASE # TODO see sprint/testcases/test_sprint.py for already existing tests # and move them if there are only-backlog-tests pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_list_different_sprint(self): # TODO TESTCASE # NOTE: another sprint has to exist to be showable pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_move_issue_to_current_sprint(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_remove_issue_from_current_sprint(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_order_by(self): # TODO TESTCASE for both backlog_list and current sprint for multiple order-by-situations pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_issue_short_names_are_shown(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_issue_names_are_shown(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_issues_types_are_shown(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_user_are_shown(self): # TODO TESTCASE pass # TODO see sprint/testcases/test_sprint.py for already existing tests and move them if there are only-backlog-tests def test_priorities_are_shown(self): # TODO TESTCASE pass def test_show_done_issues_in_finished_sprints(self): # TODO TESTCASE # TODO write a test as soon as this feature is implemented - IGU-399 pass
def test_stop_sprint_move_issues_to_new_sprint(self): # self.sprint should not have started self.assertNotEqual(self.sprint.seqnum, -1) project = Project(creator=self.user, name_short='APF') project.save() project.manager.add(self.user) sprint = Sprint(project=project) sprint.save() self.assertEqual(project.sprint.get_new_sprints().count(), 1) # columns and issues for testing archiving function kanbancol1 = KanbanColumn.objects.get(name='Todo', project=project) kanbancol2 = KanbanColumn.objects.get(name='In Progress', project=project) kanbancol3 = KanbanColumn.objects.get(name='Done', project=project) issue = Issue(title="Test-Issue", kanbancol=kanbancol1, project=project, type="Bug", sprint=sprint) issue.save() issue2 = Issue(title="Test-Issue2", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue2.save() issue3 = Issue(title="Test-Issue3", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue3.save() issue4 = Issue(title="Test-Issue4", kanbancol=kanbancol3, project=project, type="Bug") issue4.save() sprint.set_active() # move to autocreated sprint response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': [issue.number, issue2.number]}, follow=True) # new sprint created # self.sprint and sprint created during post request self.assertEqual(project.sprint.all().count(), 2) self.assertEqual(project.sprint.get_new_sprints().count(), 1) self.assertEqual(project.sprint.get_old_sprints().count(), 1) # issue, issue2 in new sprint, issue3 in backlog self.assertIn(issue, project.sprint.get_new_sprints().last().issue.all()) self.assertIn(issue2, project.sprint.get_new_sprints().last().issue.all()) self.assertNotIn(issue3, project.sprint.get_new_sprints().last().issue.all()) issue3.refresh_from_db() self.assertEqual(issue3.sprint, None) # move to existing sprint sprint = project.sprint.get_new_sprints().last() sprint.set_active() project.refresh_from_db() sprint2 = Sprint(project=project) sprint2.save() response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': sprint2.seqnum, 'move_to_new_sprint': [issue.number]}, follow=True) # issue in sprint2, issue2 moved to backlog self.assertIn(issue, sprint2.issue.all()) self.assertNotIn(issue2, sprint2.issue.all()) issue2.refresh_from_db() self.assertEqual(issue2.sprint, None)
class SprintTest(TestCase): @classmethod def setUpTestData(cls): # NOTE: if you modify this element it needs to be created in setUp, instead of here cls.user = get_user_model().objects.create_user('a', 'b', 'c') def setUp(self): self.client.force_login(self.user) # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData() self.project = Project(creator=self.user, name_short='PRJ') self.project.save() self.project.manager.add(self.user) self.sprint = Sprint(project=self.project) self.sprint.save() def test_view_and_template(self): # TODO TESTCASE see invite_users # use view_and_template() # TODO which views? # - Sprintboard - sprintboard # - NewSprint - newsprint # - StartSprint - startsprint # - StopSprint - stopsprint # - SprintEditView - editsprint # - ToggleIssueToFromSprintView - assigntosprint # - ... pass def test_redirect_to_login_and_login_required(self): self.client.logout() # TODO TESTCASE see invite_users # redirect_to_login_and_login_required() # TODO which views? # - Sprintboard - sprintboard # - NewSprint - newsprint # - StartSprint - startsprint # - StopSprint - stopsprint # - SprintEditView - editsprint # - ToggleIssueToFromSprintView - assigntosprint # - ... pass def test_user_passes_test_mixin(self): # TODO TESTCASE # TODO NewSprint # TODO StartSprint # TODO StopSprint # TODO Sprint_Edit_View pass def test_flags(self): kanbancol = KanbanColumn(name='Column', position=1, project=self.project) kanbancol.save() issue = Issue(title="Test-Issue", kanbancol=kanbancol, project=self.project, type="Bug", sprint=self.sprint) issue.save() self.assertEqual(issue.was_in_sprint, False) response = self.client.post( reverse('sprint:stopsprint', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) self.assertEqual(Issue.objects.get(pk=issue.pk).was_in_sprint, True) issue.save() # unset the flag self.assertEqual(issue.was_in_sprint, False) def test_sprint_functions(self): # sprint is new sprint self.assertTrue(self.sprint in Sprint.objects.get_new_sprints()) self.assertFalse(self.sprint in Sprint.objects.get_current_sprints()) self.assertFalse(self.sprint in Sprint.objects.get_old_sprints()) # set sprint active self.sprint.set_active() self.assertTrue(self.sprint.is_active) # sprint is new current sprint self.assertFalse(self.sprint in Sprint.objects.get_new_sprints()) self.assertTrue(self.sprint in Sprint.objects.get_current_sprints()) self.assertFalse(self.sprint in Sprint.objects.get_old_sprints()) # done and undone issue to put back in backlog kanbancoldone = KanbanColumn.objects.get(type='Done', project=self.project) kanbancolprogress = KanbanColumn.objects.get(type='InProgress', project=self.project) issuedone = Issue(title="Test-Issue", kanbancol=kanbancoldone, project=self.project, type="Bug", sprint=self.sprint) issuedone.save() issueprogress = Issue(title="Test-Issue", kanbancol=kanbancolprogress, project=self.project, type="Bug", sprint=self.sprint) issueprogress.save() # set sprint inactive issueleft = self.sprint.set_inactive() self.assertTrue(self.sprint.is_inactive()) issuedone.refresh_from_db() issueprogress.refresh_from_db() # issues are right archived and assigned self.assertTrue(issueleft) self.assertTrue(issuedone.archived) self.assertFalse(issueprogress.archived) self.assertIsNotNone(issuedone.sprint) self.assertIsNone(issueprogress.sprint) self.assertTrue(issueprogress.was_in_sprint) # sprint is new old sprint self.assertFalse(self.sprint in Sprint.objects.get_new_sprints()) self.assertFalse(self.sprint in Sprint.objects.get_current_sprints()) self.assertTrue(self.sprint in Sprint.objects.get_old_sprints()) def test_create_sprint(self): self.assertNotEqual(self.sprint.seqnum, -1) nextseqnum = self.sprint.seqnum + 1 n = Sprint.objects.count() + 1 response = self.client.get(reverse('sprint:newsprint', kwargs={'project': self.project.name_short} )) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': nextseqnum})) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertEqual(Sprint.objects.count(), n) def test_start_and_stop_sprint(self): # self.sprint should not have started self.assertNotEqual(self.sprint.seqnum, -1) project = Project(creator=self.user, name_short='APF') project.save() project.manager.add(self.user) n = Sprint.objects.get_new_sprints().count() sprint = Sprint(project=project) sprint.save() self.assertEqual(Sprint.objects.get_new_sprints().count(), (n+1)) self.assertTrue(sprint in Sprint.objects.get_new_sprints()) self.assertFalse(sprint in Sprint.objects.get_current_sprints()) self.assertFalse(sprint in Sprint.objects.get_old_sprints()) self.assertIsNone(project.currentsprint) # columns and issues for testing archiving function kanbancol3 = KanbanColumn.objects.get(name='Todo', project=project) kanbancol3.type = 'Done' kanbancol3.save() kanbancol2 = KanbanColumn.objects.get(name='In Progress', project=project) kanbancol1 = KanbanColumn.objects.get(name='Done', project=project) kanbancol1.type = 'ToDo' kanbancol1.save() issue = Issue(title="Test-Issue", kanbancol=kanbancol1, project=project, type="Bug", sprint=sprint) issue.save() issue2 = Issue(title="Test-Issue2", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue2.save() issue3 = Issue(title="Test-Issue3", kanbancol=kanbancol3, project=project, type="Bug", sprint=sprint) issue3.save() issue4 = Issue(title="Test-Issue4", kanbancol=kanbancol3, project=project, type="Bug") issue4.save() # issues (except issue4) should be in not started sprint self.assertFalse(issue in Issue.objects.without_sprint()) self.assertFalse(issue in Issue.objects.current_sprint()) self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(project.has_active_sprint()) # start sprint response = self.client.post(reverse('sprint:startsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum})) sprint.refresh_from_db() project.refresh_from_db() # sprint should be current sprint self.assertIsNotNone(project.currentsprint) self.assertEqual(project.currentsprint.seqnum, sprint.seqnum) self.assertTrue(project.has_active_sprint()) self.assertFalse(sprint in Sprint.objects.get_new_sprints()) self.assertTrue(sprint in Sprint.objects.get_current_sprints()) self.assertFalse(sprint in Sprint.objects.get_old_sprints()) # no issues archived until now self.assertFalse(issue in Issue.objects.without_sprint()) self.assertTrue(issue in Issue.objects.current_sprint()) self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(issue2 in Issue.objects.archived()) self.assertFalse(issue3 in Issue.objects.archived()) self.assertFalse(issue4 in Issue.objects.archived()) # set sprint inactive(and archive) response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': []}, follow=True) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': project.name_short})) sprint.refresh_from_db() project.refresh_from_db() # sprint should no more be current sprint. not-done-issues back in backlog (not archived, without sprint) self.assertFalse(sprint in Sprint.objects.get_new_sprints()) self.assertFalse(sprint in Sprint.objects.get_current_sprints()) self.assertTrue(sprint in Sprint.objects.get_old_sprints()) self.assertIsNone(project.currentsprint) self.assertFalse(project.has_active_sprint()) self.assertTrue(issue in Issue.objects.without_sprint()) self.assertFalse(issue in Issue.objects.current_sprint()) # issue3 is archived because of column type and finished sprint, # issue (wrong type), issue2 (wrong type) and 4 (wrong sprint) arent self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(issue2 in Issue.objects.archived()) self.assertTrue(issue3 in Issue.objects.archived()) self.assertFalse(issue4 in Issue.objects.archived()) # issue and issue4 are in same column, both without sprint issue4.kanbancol = kanbancol1 issue4.save() # archive column of issue and issue4 values = {'pos_c': kanbancol1.position} response = self.client.post(reverse('issue:archivecol', kwargs={'project': project.name_short}), values) self.assertRedirects(response, reverse('sprint:sprintboard', kwargs={'project': project.name_short})) issue4.refresh_from_db() self.assertTrue(issue in Issue.objects.archived()) # archived by archivecol self.assertFalse(issue2 in Issue.objects.archived()) # not archived wrong type self.assertTrue(issue3 in Issue.objects.archived()) # archived by stopsprint self.assertTrue(issue4 in Issue.objects.archived()) # archived by archivecol def test_edit_sprint(self): self.assertNotEqual(self.sprint.seqnum, -1) planned_date = datetime.date.today() + datetime.timedelta(days=10) values = {'plandate': planned_date} response = self.client.post(reverse('sprint:editsprint', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum} ), values) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertEqual(Sprint.objects.first().plandate, planned_date) def test_add_and_remove_issue_from_sprint(self): kanbancol = KanbanColumn(name='Column', position=1, project=self.project) kanbancol.save() issue = Issue(title="Test-Issue", kanbancol=kanbancol, project=self.project, type="Bug") issue.save() # add to sprint response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) self.assertEqual(Issue.objects.get(pk=issue.pk).sprint, Sprint.objects.get(pk=self.sprint.pk)) # remove from sprint response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_s': self.sprint.seqnum, 'sqn_i': issue.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short}) ) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) self.assertEqual(Issue.objects.get(pk=issue.pk).sprint, None) def test_dont_assign_issues_to_stoped_sprints(self): issue = Issue(title="Test-Issue", project=self.project, type="Bug") issue.save() issue2 = Issue(title="Test-Issue2", project=self.project, type="Bug") issue2.save() # start sprint self.sprint.set_active() self.sprint.save() self.project.currentsprint = self.sprint self.project.save() # assign first issue response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) # first issue is part of the sprint issue.refresh_from_db() self.assertIsNotNone(issue.sprint) # stop sprint response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': []}, follow=True) self.assertEqual(Issue.objects.get(pk=issue.pk).was_in_sprint, True) # assign second issue => should fail response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue2.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short})) # second issue is NOT part of the sprint issue2.refresh_from_db() self.assertIsNone(issue2.sprint) # create new sprint - so we don't run into the not-sprint part but really into the atomic check for enddate sprint2 = Sprint(project=self.project) sprint2.save() response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}), {'sqn_i': issue2.number}, follow=True, HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short, 'sqn_s': self.sprint.seqnum})) issue2.refresh_from_db() self.assertIsNone(issue2.sprint) def test_stop_sprint_move_issues_to_new_sprint(self): # self.sprint should not have started self.assertNotEqual(self.sprint.seqnum, -1) project = Project(creator=self.user, name_short='APF') project.save() project.manager.add(self.user) sprint = Sprint(project=project) sprint.save() self.assertEqual(project.sprint.get_new_sprints().count(), 1) # columns and issues for testing archiving function kanbancol1 = KanbanColumn.objects.get(name='Todo', project=project) kanbancol2 = KanbanColumn.objects.get(name='In Progress', project=project) kanbancol3 = KanbanColumn.objects.get(name='Done', project=project) issue = Issue(title="Test-Issue", kanbancol=kanbancol1, project=project, type="Bug", sprint=sprint) issue.save() issue2 = Issue(title="Test-Issue2", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue2.save() issue3 = Issue(title="Test-Issue3", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue3.save() issue4 = Issue(title="Test-Issue4", kanbancol=kanbancol3, project=project, type="Bug") issue4.save() sprint.set_active() # move to autocreated sprint response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': [issue.number, issue2.number]}, follow=True) # new sprint created # self.sprint and sprint created during post request self.assertEqual(project.sprint.all().count(), 2) self.assertEqual(project.sprint.get_new_sprints().count(), 1) self.assertEqual(project.sprint.get_old_sprints().count(), 1) # issue, issue2 in new sprint, issue3 in backlog self.assertIn(issue, project.sprint.get_new_sprints().last().issue.all()) self.assertIn(issue2, project.sprint.get_new_sprints().last().issue.all()) self.assertNotIn(issue3, project.sprint.get_new_sprints().last().issue.all()) issue3.refresh_from_db() self.assertEqual(issue3.sprint, None) # move to existing sprint sprint = project.sprint.get_new_sprints().last() sprint.set_active() project.refresh_from_db() sprint2 = Sprint(project=project) sprint2.save() response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': sprint2.seqnum, 'move_to_new_sprint': [issue.number]}, follow=True) # issue in sprint2, issue2 moved to backlog self.assertIn(issue, sprint2.issue.all()) self.assertNotIn(issue2, sprint2.issue.all()) issue2.refresh_from_db() self.assertEqual(issue2.sprint, None) # TODO TESTCASE - move to issue/testcase/test_backlog.py? def test_storypoints_in_backlog(self): kanbancol = KanbanColumn(name='Column', position=1, project=self.project) kanbancol.save() issue = Issue(title="Test-Issue", kanbancol=kanbancol, project=self.project, type="Bug", sprint=self.sprint) issue.save() response = self.client.get(reverse('backlog:backlog', kwargs={'project': self.project.name_short} )) self.assertNotContains(response, 'Storypoints:') issue.storypoints = 5 issue.save() response = self.client.get(reverse('backlog:backlog', kwargs={'project': self.project.name_short} )) self.assertNotContains(response, 'Storypoints:') issue.assignee.add(self.user) response = self.client.get(reverse('backlog:backlog', kwargs={'project': self.project.name_short} )) self.assertContains(response, 'Storypoints:') self.assertContains(response, str(self.user.username) + ': 5') user2 = get_user_model().objects.create_user('a2', 'b2', 'c2') user2.save() self.project.developer.add(user2) issue.assignee.add(user2) response = self.client.get(reverse('backlog:backlog', kwargs={'project': self.project.name_short} )) self.assertContains(response, str(user2.username) + ': 2.5') self.assertContains(response, str(self.user.username) + ': 2.5') issue2 = Issue(title="Test-Issue", kanbancol=kanbancol, project=self.project, type="Bug", sprint=self.sprint, storypoints=5) issue2.save() issue2.assignee.add(self.user) response = self.client.get(reverse('backlog:backlog', kwargs={'project': self.project.name_short} )) self.assertContains(response, str(user2.username) + ': 2.5') self.assertContains(response, str(self.user.username) + ': 7.5')
def test_start_and_stop_sprint(self): # self.sprint should not have started self.assertNotEqual(self.sprint.seqnum, -1) project = Project(creator=self.user, name_short='APF') project.save() project.manager.add(self.user) n = Sprint.objects.get_new_sprints().count() sprint = Sprint(project=project) sprint.save() self.assertEqual(Sprint.objects.get_new_sprints().count(), (n+1)) self.assertTrue(sprint in Sprint.objects.get_new_sprints()) self.assertFalse(sprint in Sprint.objects.get_current_sprints()) self.assertFalse(sprint in Sprint.objects.get_old_sprints()) self.assertIsNone(project.currentsprint) # columns and issues for testing archiving function kanbancol3 = KanbanColumn.objects.get(name='Todo', project=project) kanbancol3.type = 'Done' kanbancol3.save() kanbancol2 = KanbanColumn.objects.get(name='In Progress', project=project) kanbancol1 = KanbanColumn.objects.get(name='Done', project=project) kanbancol1.type = 'ToDo' kanbancol1.save() issue = Issue(title="Test-Issue", kanbancol=kanbancol1, project=project, type="Bug", sprint=sprint) issue.save() issue2 = Issue(title="Test-Issue2", kanbancol=kanbancol2, project=project, type="Bug", sprint=sprint) issue2.save() issue3 = Issue(title="Test-Issue3", kanbancol=kanbancol3, project=project, type="Bug", sprint=sprint) issue3.save() issue4 = Issue(title="Test-Issue4", kanbancol=kanbancol3, project=project, type="Bug") issue4.save() # issues (except issue4) should be in not started sprint self.assertFalse(issue in Issue.objects.without_sprint()) self.assertFalse(issue in Issue.objects.current_sprint()) self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(project.has_active_sprint()) # start sprint response = self.client.post(reverse('sprint:startsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum})) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum})) sprint.refresh_from_db() project.refresh_from_db() # sprint should be current sprint self.assertIsNotNone(project.currentsprint) self.assertEqual(project.currentsprint.seqnum, sprint.seqnum) self.assertTrue(project.has_active_sprint()) self.assertFalse(sprint in Sprint.objects.get_new_sprints()) self.assertTrue(sprint in Sprint.objects.get_current_sprints()) self.assertFalse(sprint in Sprint.objects.get_old_sprints()) # no issues archived until now self.assertFalse(issue in Issue.objects.without_sprint()) self.assertTrue(issue in Issue.objects.current_sprint()) self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(issue2 in Issue.objects.archived()) self.assertFalse(issue3 in Issue.objects.archived()) self.assertFalse(issue4 in Issue.objects.archived()) # set sprint inactive(and archive) response = self.client.post(reverse('sprint:stopsprint', kwargs={'project': project.name_short, 'sqn_s': sprint.seqnum}), {'sprint': 'new', 'move_to_new_sprint': []}, follow=True) self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': project.name_short})) sprint.refresh_from_db() project.refresh_from_db() # sprint should no more be current sprint. not-done-issues back in backlog (not archived, without sprint) self.assertFalse(sprint in Sprint.objects.get_new_sprints()) self.assertFalse(sprint in Sprint.objects.get_current_sprints()) self.assertTrue(sprint in Sprint.objects.get_old_sprints()) self.assertIsNone(project.currentsprint) self.assertFalse(project.has_active_sprint()) self.assertTrue(issue in Issue.objects.without_sprint()) self.assertFalse(issue in Issue.objects.current_sprint()) # issue3 is archived because of column type and finished sprint, # issue (wrong type), issue2 (wrong type) and 4 (wrong sprint) arent self.assertFalse(issue in Issue.objects.archived()) self.assertFalse(issue2 in Issue.objects.archived()) self.assertTrue(issue3 in Issue.objects.archived()) self.assertFalse(issue4 in Issue.objects.archived()) # issue and issue4 are in same column, both without sprint issue4.kanbancol = kanbancol1 issue4.save() # archive column of issue and issue4 values = {'pos_c': kanbancol1.position} response = self.client.post(reverse('issue:archivecol', kwargs={'project': project.name_short}), values) self.assertRedirects(response, reverse('sprint:sprintboard', kwargs={'project': project.name_short})) issue4.refresh_from_db() self.assertTrue(issue in Issue.objects.archived()) # archived by archivecol self.assertFalse(issue2 in Issue.objects.archived()) # not archived wrong type self.assertTrue(issue3 in Issue.objects.archived()) # archived by stopsprint self.assertTrue(issue4 in Issue.objects.archived()) # archived by archivecol