Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
    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()