def test_create_userstory_from_issue_by_membership(self): issue = create_issue(1, self.user2, self.project1, self.milestone1) data = { "subject": "Test UserStory creation from issue", "description": "A Test UserStory example description", "project": self.project1.id, "milestone": self.milestone1.id, "status": self.project1.us_statuses.all()[1].id, "generated_from_issue": issue.id, "issue_comment": "This is a test example", "generated_from_issue": issue.id } self.assertEqual(UserStory.objects.all().count(), 4) self.assertEqual(len(mail.outbox), 0) response = self.client.login(username=self.user2.username, password=self.user2.username) self.assertTrue(response) response = self.client.post( reverse("userstories-list"), json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 201) self.assertEqual(UserStory.objects.all().count(), 5) self.assertEqual(len(mail.outbox), 1) self.assertEqual(response.data["origin_issue"]["subject"], issue.subject) issue_historical = reversion.get_unique_for_object(issue) self.assertTrue(data["subject"] in issue_historical[0].revision.comment) self.client.logout()
def test_issue(self): issue = create_issue(1, self.user1, self.project1) notified = issue.get_watchers_to_notify(self.user1) expected_notified = [self.user2, self.user3, self.user4, self.user5] self.assertEqual(notified,set(expected_notified)) issue.delete()
def test_create_userstory_from_issue_by_membership(self): issue = create_issue(1, self.user2, self.project1, self.milestone1) data = { "subject": "Test UserStory creation from issue", "description": "A Test UserStory example description", "project": self.project1.id, "milestone": self.milestone1.id, "status": self.project1.us_statuses.all()[1].id, "generated_from_issue": issue.id, "issue_comment": "This is a test example", "generated_from_issue": issue.id } self.assertEqual(UserStory.objects.all().count(), 4) self.assertEqual(len(mail.outbox), 0) response = self.client.login(username=self.user2.username, password=self.user2.username) self.assertTrue(response) response = self.client.post( reverse("userstories-list"), json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 201) self.assertEqual(UserStory.objects.all().count(), 5) self.assertEqual(len(mail.outbox), 2) self.assertEqual(response.data["origin_issue"]["subject"], issue.subject) self.client.logout()
def test_emit_change_for_model(self): user = create_user(1) # Project owner project = create_project(1, user) issue = create_issue(1, user, project) with patch("taiga.events.backends.get_events_backend") as mock_instance: ch.emit_change_event_for_model(issue, "sessionid") self.assertTrue(mock_instance.return_value.emit_event.called)
def test_emit_change_for_model(self): user = create_user(1) # Project owner project = create_project(1, user) issue = create_issue(1, user, project) with patch( "taiga.events.backends.get_events_backend") as mock_instance: ch.emit_change_event_for_model(issue, "sessionid") self.assertTrue(mock_instance.return_value.emit_event.called)
def test_issue_with_owner_notification(self): self.user1.notify_changes_by_me = True self.user1.save() issue = create_issue(1, self.user1, self.project1) notified = issue.get_watchers_to_notify(self.user1) expected_notified = [self.user1, self.user2, self.user3, self.user4, self.user5] self.assertEqual(notified,set(expected_notified)) issue.delete() self.user1.notify_changes_by_me = False self.user1.save()
def test_create_userstory_from_issue_by_anon(self): issue = create_issue(1, self.user2, self.project1, self.milestone1) data = { "subject": "Test UserStory", "description": "A Test UserStory example description", "project": self.project1.id, "milestone": self.milestone1.id, "status": self.project1.us_statuses.all()[1].id, "generated_from_issue": issue.id } self.assertEqual(UserStory.objects.all().count(), 4) response = self.client.post( reverse("userstories-list"), json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 401) self.assertEqual(UserStory.objects.all().count(), 4)
def test_create_userstory_from_issue_by_no_membership(self): issue = create_issue(1, self.user2, self.project1, self.milestone1) data = { "subject": "Test UserStory", "description": "A Test UserStory example description", "project": self.project1.id, "milestone": self.milestone1.id, "status": self.project1.us_statuses.all()[1].id, "generated_from_issue": issue.id } self.assertEqual(UserStory.objects.all().count(), 4) self.assertEqual(len(mail.outbox), 0) response = self.client.login(username=self.user4.username, password=self.user4.username) self.assertTrue(response) response = self.client.post( reverse("userstories-list"), json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 403) self.assertEqual(UserStory.objects.all().count(), 4) self.client.logout()