def test_add_device(self): """Test for add_device method""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") d1 = Devices("PC", "Dell", "xps", "2018", "3rd Floor") self.assertEqual(len(e1.device_list), 0) e1.add_device(d1) self.assertIn(d1, e1.device_list)
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)
def test_set_yer(self): """Test for set_get_year methods""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") e1.set_year("1950") self.assertEqual(e1.get_year(), "1950")
def test_set_publisher(self): """Test for set_get_publisher methods""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") e1.set_publisher("Bloomsbury") self.assertEqual(e1.get_publisher(), "Bloomsbury")
def test_set_author(self): """Test for set_get_author methods""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") e1.set_author("Samuel Beckett") self.assertEqual(e1.get_author(), "Samuel Beckett")
def test_set_title(self): """Test for set_get_title methods""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") e1.set_title("Animal Farm") self.assertEqual(e1.get_title(), "Animal Farm")
def test_eResource_creation(self): """Test for eResource creation""" e1 = E_Resources("1984", "George Orwell", "Harvill Secker", "1949") self.assertEqual(e1.get_title(), "1984")