示例#1
0
 def test_sort_books(self):
     slash_book = slash_to_book(["1993", "Steve", "McConnell",
                                 "Code Complete"])
     csv_book = csv_to_book(["Clean Code", "Martin", "Robert", "2008"])
     kent_book_1 = pipe_to_book(["Kent", "Beck", "Test-Driven Development",
                                 "2002"])
     kent_book_2 = pipe_to_book(["Kent", "Beck", "Implementation Patterns",
                                "2007"])
     books = [slash_book, kent_book_1, kent_book_2, csv_book]
     random.shuffle(books)
     self.assertEquals(sort_books(books), [kent_book_2, kent_book_1,
                                           csv_book, slash_book])
     self.assertEquals(sort_books(books, True), [slash_book, kent_book_1,
                                                 kent_book_2,csv_book])
     self.assertEquals(sort_books(books, True, True), [csv_book,
                                                       kent_book_2,
                                                       kent_book_1,
                                                       slash_book])
示例#2
0
 def test_book_concat_fields(self):
     book = pipe_to_book(["Kent", "Beck", "Test-Driven Development", "2002"])
     self.assertEquals(book.concat_fields(),
                       "KentBeckTest-Driven Development2002")
示例#3
0
 def test_pipe_conversion(self):
     fields = ["Kent", "Beck", "Test-Driven Development", "2002"]
     self._assert_book_conversion(pipe_to_book(fields), fields)