Exemple #1
0
    def test_partial_snapshots(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test1"
        userstory1.save()
        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test2"
        userstory1.save()
        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test3"
        userstory1.save()
        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test4"
        userstory1.save()
        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test5"
        userstory1.save()
        hentry = history.take_snapshot(userstory1)

        self.assertEqual(models.HistoryEntry.objects.count(), 6)
        self.assertEqual(
            models.HistoryEntry.objects.filter(is_snapshot=True).count(), 1)
        self.assertEqual(
            models.HistoryEntry.objects.filter(is_snapshot=False).count(), 5)
Exemple #2
0
    def test_comment(self):
        userstory1 = create_userstory(1, self.user1, self.project1)

        self.assertEqual(models.HistoryEntry.objects.count(), 0)
        hentry = history.take_snapshot(userstory1, comment="Sample comment")

        self.assertEqual(models.HistoryEntry.objects.count(), 1)
        self.assertEqual(hentry.comment, "Sample comment")
Exemple #3
0
    def setUp(self):
        self.user1 = create_user(1) # Project owner
        self.user2 = create_user(2) # Owner
        self.user3 = create_user(3) # Membership
        self.user4 = create_user(4) # No Membership

        self.project1 = create_project(1, self.user1)
        add_membership(self.project1, self.user2)
        add_membership(self.project1, self.user3)
        self.milestone1 = create_milestone(1, self.user2, self.project1)
        self.userstory1 = create_userstory(1, self.user2, self.project1, self.milestone1)
        self.userstory2 = create_userstory(2, self.user2, self.project1, self.milestone1)
        self.userstory3 = create_userstory(3, self.user2, self.project1)
        self.task1 = create_task(1, self.user2, self.project1, None, self.userstory1)
        self.task2 = create_task(2, self.user3, self.project1, None, self.userstory1)
        self.task3 = create_task(3, self.user2, self.project1, None, self.userstory2)
        self.task4 = create_task(4, self.user3, self.project1, self.milestone1)

        self.project2 = create_project(2, self.user4)
        self.milestone2 = create_milestone(2, self.user4, self.project2)
        self.userstory4 = create_userstory(4, self.user4, self.project2)
        self.task5 = create_task(5, self.user4, self.project2, self.milestone2)
Exemple #4
0
    def setUp(self):
        self.user1 = create_user(1) # Project owner
        self.user2 = create_user(2) # Owner
        self.user3 = create_user(3) # Membership
        self.user4 = create_user(4) # No Membership

        self.project1 = create_project(1, self.user1)
        add_membership(self.project1, self.user2)
        add_membership(self.project1, self.user3)
        self.milestone1 = create_milestone(1, self.user2, self.project1)
        self.userstory1 = create_userstory(1, self.user2, self.project1, self.milestone1)
        self.userstory2 = create_userstory(2, self.user2, self.project1, self.milestone1)
        self.userstory3 = create_userstory(3, self.user2, self.project1)
        self.task1 = create_task(1, self.user2, self.project1, None, self.userstory1)
        self.task2 = create_task(2, self.user3, self.project1, None, self.userstory1)
        self.task3 = create_task(3, self.user2, self.project1, None, self.userstory2)
        self.task4 = create_task(4, self.user3, self.project1, self.milestone1)

        self.project2 = create_project(2, self.user4)
        self.milestone2 = create_milestone(2, self.user4, self.project2)
        self.userstory4 = create_userstory(4, self.user4, self.project2)
        self.task5 = create_task(5, self.user4, self.project2, self.milestone2)
Exemple #5
0
    def test_diff(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        userstory1.subject = "test1"
        userstory1.save()

        fobj1 = history.freeze_model_instance(userstory1)

        userstory1.subject = "test2"
        userstory1.save()

        fobj2 = history.freeze_model_instance(userstory1)

        fdiff = history.make_diff(fobj1, fobj2)
        self.assertEqual(fdiff.diff, {"subject": ('test1', 'test2')})
Exemple #6
0
    def test_snapshot(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        userstory1.subject = "test1"
        userstory1.save()

        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test2"
        userstory1.save()

        self.assertEqual(hentry.key,
                         "userstories.userstory:{}".format(userstory1.id))
        self.assertEqual(models.HistoryEntry.objects.count(), 1)

        history.take_snapshot(userstory1)
        self.assertEqual(models.HistoryEntry.objects.count(), 2)
Exemple #7
0
    def test_list_history_entries(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        userstory1.subject = "test1"
        userstory1.save()

        history.take_snapshot(userstory1)
        userstory1.subject = "test2"
        userstory1.save()

        history.take_snapshot(userstory1)

        response = self.client.login(username=self.user1.username,
                                     password=self.user1.username)

        url = reverse("userstory-history-detail", args=[userstory1.pk])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
Exemple #8
0
    def test_values(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        userstory1.subject = "test1"
        userstory1.save()

        hentry = history.take_snapshot(userstory1)

        userstory1.subject = "test2"
        userstory1.assigned_to = self.user1
        userstory1.save()

        hentry = history.take_snapshot(userstory1)

        self.assertIn("users", hentry.values)
        self.assertEqual(len(hentry.values), 1)
        self.assertIn("assigned_to", hentry.values_diff)
        self.assertEqual(hentry.values_diff["assigned_to"],
                         [None, "Foo1 Bar1"])
Exemple #9
0
    def test_userstory_points(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        hentry = history.take_snapshot(userstory1)

        self.assertEqual({}, hentry.values_diff)

        rpmodel_cls = get_model("userstories", "RolePoints")
        pmodel_cls = get_model("projects", "Points")

        rolepoints = rpmodel_cls.objects.filter(user_story=userstory1)[0]
        points = pmodel_cls.objects.get(project=userstory1.project, value=15)

        rolepoints.points = points
        rolepoints.save()

        hentry = history.take_snapshot(userstory1)

        self.assertIn("points", hentry.values_diff)
        self.assertIn("UX", hentry.values_diff["points"])
        self.assertEqual(hentry.values_diff["points"]["UX"], ["?", "15"])
Exemple #10
0
    def test_userstory_attachments(self):
        userstory1 = create_userstory(1, self.user1, self.project1)
        hentry = history.take_snapshot(userstory1)

        self.assertEqual({}, hentry.values_diff)

        # Create attachment file
        attachment_modelcls = get_model("attachments", "Attachment")

        content_type = ContentType.objects.get_for_model(userstory1.__class__)
        temporary_file = SimpleUploadedFile("text.txt", b"sample content")
        attachment = attachment_modelcls.objects.create(
            project=userstory1.project,
            content_type=content_type,
            content_object=userstory1,
            object_id=userstory1.id,
            owner=self.user1,
            attached_file=temporary_file)

        hentry = history.take_snapshot(userstory1)
        self.assertIn("attachments", hentry.values_diff)