Ejemplo n.º 1
0
 def send_notification(self):
     """Test for send_notification method"""
     s1 = System()
     b1 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     m1 = Members("Richard", "Blackmore", "14-04-1945", "Weston")
     s1.send_notification("Please return book")
     self.assertEqual(m1.get_notifications(), None)
     s1.add_resource(b1)
     s1.lending_process(b1, m1)
     s1.send_notification("Please return book")
     self.assertEqual(m1.get_notifications(), "-Please return boo- ")
Ejemplo n.º 2
0
 def return_book_process(self):
     """Test for return_book_process method"""
     s1 = System()
     b1 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     m1 = Members("Richard", "Blackmore", "14-04-1945", "Weston")
     s1.add_resource(b1)
     s1.lending_process(b1, m1)
     s1.remove_resource(b1)
     #prove that the return of a book doen't take place if not in the ctalogue, 
     #but also that in the remove_resource method should be added somthing to remeove that book from all borrowers
     #or doesn't allow the operation if not returned
     s1.return_book_process(b1, False, "none")
     self.assertEqual(b1.get_borrower(), m1)
     self.assertIn(b1, m1.get_borrowed_books())
     s1.add_resource(b1)
     self.assertEqual(b1.get_borrower(), None)
     self.assertNotIn(b1, m1.get_borrowed_books())
Ejemplo n.º 3
0
 def test_lending_process(self):
     """Test for lending_process method"""
     s1 = System()
     b1 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     m1 = Members("Richard", "Blackmore", "14-04-1945", "Weston")
     m2 = Members("Eric", "Eric Clapton", "30-03-1945", "Riplay")
     #test what happens if book not in the catalogue
     s1.lending_process(b1, m1)
     self.assertEqual(b1.get_borrower(), None)
     self.assertNotIn(b1, m1.get_borrowed_books())
     #test what happens if book in the catalogue
     s1.add_resource(b1)
     s1.lending_process(b1, m1)
     self.assertEqual(b1.get_borrower(), m1)
     self.assertIn(b1, m1.get_borrowed_books())
     #test what happens if book already borrowed
     s1.lending_process(b1, m2)
     self.assertEqual(b1.get_borrower(), m1)
     self.assertIn(b1, m1.get_borrowed_books())
     self.assertNotIn(b1, m2.get_borrowed_books())
     #test what happens if eResource is tried to be borrowed
     e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949")
     s1.add_resource(e1)
     s1.lending_process(e1, m2)
     self.assertNotIn(e1, m2.get_borrowed_books())
     #test what happens if the same book is added 2 times to the same member
     s1.lending_process(b1, m1)
     self.assertEqual(m1.get_borrowed_books_lengh(), 1)
     #test what happens if is tried to borrow more than 5 books:
     #2
     b2 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     s1.add_resource(b2)
     s1.lending_process(b2, m1)
     self.assertEqual(b2.get_borrower(), m1)
     self.assertEqual(m1.get_borrowed_books_lengh(), 2)
     #3
     b3 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     s1.add_resource(b3)
     s1.lending_process(b3, m1)
     self.assertEqual(b3.get_borrower(), m1)
     self.assertEqual(m1.get_borrowed_books_lengh(), 3)
     #4
     b4 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     s1.add_resource(b4)
     s1.lending_process(b4, m1)
     self.assertEqual(b4.get_borrower(), m1)
     self.assertEqual(m1.get_borrowed_books_lengh(), 4)
     #5
     b5 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     s1.add_resource(b5)
     s1.lending_process(b5, m1)
     self.assertEqual(b5.get_borrower(), m1)
     self.assertEqual(m1.get_borrowed_books_lengh(), 5)
     #6
     b6 = Books("1984", "George Orwell", "Harvill Secker", "1949", "0123456789123")
     s1.add_resource(b6)
     s1.lending_process(b6, m1)
     self.assertEqual(b6.get_borrower(), None)
     self.assertEqual(m1.get_borrowed_books_lengh(), 5)