示例#1
0
    def test_relationship_ticket_comment(self):
        # Build a user
        projectUser = ProjectUser()
        projectUser.build_user("first_user", "first", "last", "*****@*****.**")
        projectUser.save()

        projectUser2 = ProjectUser()
        projectUser2.build_user("second_user", "first", "last", "*****@*****.**")
        projectUser2.save()

        # Build a ticket
        t = Ticket()
        t.creator = projectUser
        t.name = "name"
        s = Status()
        s.name = "FakeState"
        s.save()
        t.status = s
        t.description = "description"
        t.open_date = datetime.datetime(2009, 12, 24)
        t.close_date = datetime.datetime(2010, 01, 29)
        t.priority = 3
        t.save()

        # build first comment
        c1 = t.comments.create(user=projectUser, message="First")

        # build second comment
        c2 = t.comments.create(user=projectUser2, message="Second")

        t.save()

        t2 = Ticket.objects.get(name="name")
        comments = t2.comments.all()
        self.failUnlessEqual("First", comments[0].message)
示例#2
0
    def test_model_ticket(self):
        """
        Tests the Ticket model
        """
        t = Ticket()
        t.name = "name"
        s = Status()
        s.name = "FakeState"
        s.save()
        t.status = s
        t.description = "description"
        t.open_date = datetime.datetime(2009, 12, 24)
        t.close_date = datetime.datetime(2010, 01, 29)

        projectUser = ProjectUser()
        projectUser.build_user("testuser", "first", "last", "*****@*****.**")
        projectUser.save()
        t.creator = projectUser

        t.priority = 3
        t.save()
        t2 = Ticket.objects.get(name="name")
        self.failUnlessEqual(t.name, t2.name)
        self.failUnlessEqual(t.status, t2.status)
        self.failUnlessEqual(t.description, t2.description)
        self.failUnlessEqual(t.open_date.year, t2.open_date.year)
        self.failUnlessEqual(t.close_date.year, t2.close_date.year)
        self.failUnlessEqual(t.creator, t2.creator)
        self.failUnlessEqual(t.priority, t2.priority)
        self.failUnlessEqual(str(t2), t2.name)