コード例 #1
0
 def test_domains(self):
     '''
     tests the implicit functions of book, client and rent domains
     '''
     book1 = Book(1, "Persona 3", "3rd entry in the series", "Shuji Sogabe")
     book2 = Book(2, "Persona 5", "5th entry in the series", "Atlus")
     assert book1.get_id() == 1
     assert book2.get_title() == "Persona 5"
     assert book1.get_desc() == "3rd entry in the series"
     assert book2.get_author() == "Atlus"
     assert Book.__str__(
         book1
     ) == "Persona 3 by Shuji Sogabe described as '3rd entry in the series' with id 1"
     try:
         Book("Five", 5, 324, "Name")
         assert False
     except ValueError:
         pass
     book1.set_id(8)
     book1.set_author("banana")
     book1.set_title("coconut")
     book1.set_desc("fruits")
     assert book1.get_id() == 8
     assert book1.get_desc() == "fruits"
     assert book1.get_author() == "banana"
     assert book1.get_title() == "coconut"
     client1 = Client(1, "Scott Fitzgerald")
     client2 = Client(2, "Shuji Sogabe")
     assert client1.get_id() == 1
     assert client2.get_name() == "Shuji Sogabe"
     assert Client.__str__(client1) == "Scott Fitzgerald with id 1"
     try:
         Client("Five", "Name")
         assert False
     except ValueError:
         pass
     client1.set_id(8)
     client1.set_name("banana")
     assert client1.get_id() == 8
     assert client1.get_name() == "banana"
     rent = Rental(12, 23, 34, datetime(2018, 2, 2), datetime(2018, 2, 16),
                   datetime(2018, 2, 10))
     assert rent.get_bookID() == 23
     assert rent.get_clientID() == 12
     assert rent.get_rentalID() == 34
     assert str(rent.get_due_date()) == "2018-02-16 00:00:00"
     assert str(rent.get_return_date()) == "2018-02-10 00:00:00"
     assert str(rent.get_rented_date()) == "2018-02-02 00:00:00"
     rent.set_bookID(23)
     rent.set_clientID(9)
     rent.set_rentalID(10)
     rent.set_rented_date(datetime(2018, 11, 3))
     rent.set_return_date(datetime(2018, 8, 31))
     rent.set_due_date(datetime(2018, 2, 8))
     assert rent.get_bookID() == 23
     assert rent.get_clientID() == 9
     assert rent.get_rentalID() == 10
     assert str(rent.get_due_date()) == "2018-02-08 00:00:00"
     assert str(rent.get_return_date()) == "2018-08-31 00:00:00"
     assert str(rent.get_rented_date()) == "2018-11-03 00:00:00"