def setup(self):
     self.name = "TIK-1111"
     self.sut = Ticket(self.name)
Пример #2
0
 def tickets(self):
     return [ticket for ticket in Ticket.all() if ticket.passenger == self]
class TestTicketClass:

    def setup(self):
        self.name = "TIK-1111"
        self.sut = Ticket(self.name)

    def teardown(self):
        self.name = None
        self.sut = None

    def test_init_works_as_expected(self):
        eq_(self.name, self.sut.name)
        assert_is_none(self.sut.ticket_url)
        eq_(0, self.sut.commits)
        eq_([], self.sut.authors)

    def test_add_author_doesnt_allow_duplicates(self):
        name = "Bob Dole"
        email = "*****@*****.**"

        self.sut.add_author(name, email)
        eq_(1, len(self.sut.authors))

        self.sut.add_author(name, email)
        eq_(1, len(self.sut.authors))

    def test_increment_commits_works(self):
        eq_(0, self.sut.commits)
        self.sut.increment_commits()
        eq_(1, self.sut.commits)
        self.sut.increment_commits()
        eq_(2, self.sut.commits)

    def test_str_works_as_expected(self):
        self.sut.add_author("Bob Dole", "*****@*****.**")
        self.sut.add_author("Tommy The Cat", "*****@*****.**")
        self.sut.increment_commits()
        self.sut.increment_commits()
        self.sut.ticket_url = "http://tickets/"

        expected = "\n".join([
            "[__TIK-1111__](http://tickets/TIK-1111) (2 commits)",
            "   - Bob Dole <*****@*****.**>",
            "   - Tommy The Cat <*****@*****.**>",
            ""
        ])

        eq_(expected, str(self.sut))

    def test_eq_works_as_expected(self):
        sut1 = self.sut
        sut2 = Ticket(self.name)

        eq_(sut1, sut2)