Ejemplo n.º 1
0
    def testCreateBook(self):
        '''
        Function that checks whether a book object is created correctly or not
        input:-
        preconditions:-
        output:-
        postconditions: If a book object is incorrectly created, an error will appera
        '''
        book = Book(3, "Fancy name", "Fancy description", "Fancy author name")
        self.assertEqual(book._Book__getId(), 3)
        self.assertEqual(book._Book__getTitle(), "Fancy name")
        self.assertEqual(book._Book__getDescription(), "Fancy description")
        self.assertEqual(book._Book__getAuthor(), "Fancy author name")

        book._Book__setId(5)
        self.assertEqual(book._Book__getId(), 5)
        book._Book__setTitle("New title")
        self.assertEqual(book._Book__getTitle(), "New title")
        book._Book__setDescription("New description")
        self.assertEqual(book._Book__getDescription(), "New description")
        book._Book__setAuthor("New author")
        self.assertEqual(book._Book__getAuthor(), "New author")
Ejemplo n.º 2
0
    def testUpdateBook(self):
        '''
        Function that checks whether a book is updated correctly or not, without risking to create duplicates
        input:- 
        preconditions:-
        output:-
        postconditions: If the update of a book is incorrectly implemented, an error will appear
        '''
        mylist = []
        book1 = Book(3, "Love", "Amazing", "Doctor Love")
        book2 = Book(2, "Curtains", "A complete guide to curtains",
                     "Senor Draperie")
        book1._Book__addBook(mylist)
        book2._Book__addBook(mylist)
        book1._Book__updateBook(3, 1, "A", "B", "C", mylist)

        self.assertEqual(book1._Book__getId(), 1)
        self.assertEqual(book1._Book__getTitle(), "A")
        self.assertEqual(book1._Book__getDescription(), "B")
        self.assertEqual(book1._Book__getAuthor(), "C")