Esempio n. 1
0
 def __test_book_validator():
     """
     Class for testing validator class
     :return: None
     """
     b = Book("Ion", "Liviu Rebreanu", "Drama", 1912)
     b.set_id(1)
     val = BookValidator()
     val.validate(b)
     b1 = Book("", "", "", -1)
     try:
         b1.set_id(-2)
         val.validate(b1)
         assert False
     except ValidatorException as ex:
         errs = ex.get_errs()
         assert len(errs) == 5
     try:
         b1.set_writer(5)
         assert False
     except TypeError:
         assert True
     try:
         b1.set_title(5)
         assert False
     except TypeError:
         assert True
     try:
         b1.set_genre(5)
         assert False
     except TypeError:
         assert True
     try:
         b1.set_year("asda")
         assert False
     except TypeError:
         assert True
     try:
         b1.set_id(":")
         assert False
     except TypeError:
         assert True
Esempio n. 2
0
 def __test_book():
     """
     Class for testing the book class
     :return: None
     """
     b = Book("Ion", "Liviu Rebreanu", "Drama", 1912)
     assert b.get_genre() == "Drama"
     assert b.get_id() is None
     assert b.get_year() == 1912
     assert b.get_title() == "Ion"
     assert b.get_writer() == "Liviu Rebreanu"
     b.set_genre("Actiune")
     b.set_id(1)
     b.set_title("Andrei Calin")
     b.set_writer("Alexandru Macovei")
     b.set_year(1962)
     assert b.get_genre() == "Actiune"
     assert b.get_id() == 1
     assert b.get_year() == 1962
     assert b.get_title() == "Andrei Calin"
     assert b.get_writer() == "Alexandru Macovei"