예제 #1
0
 def test_insert_new_patron_again(self):
     lib_db = Library_DB()
     with patch('library.patron.Patron') as mock_patron:
         mock_db = MagicMock()
         mock_db.search.return_value = [{
             'fname': "q",
             'lname': "b",
             'age': 12,
             'memberID': 7
         }]
         lib_db.db = mock_db
         self.assertEqual(lib_db.insert_patron(mock_patron), None)
예제 #2
0
    def test_update_patron_some(self):
        lib_db = Library_DB()
        mock_patron = MagicMock()
        mock_patron.get_fname.return_value = "f"
        mock_patron.get_lname.return_value = ";"
        mock_patron.get_age.return_value = 21
        mock_patron.get_memberID.return_value = 5
        mock_patron.get_borrowed_books.return_value = []

        mock_db = MagicMock()
        mock_db.update.return_value = {}
        lib_db.db = mock_db
        self.assertIsNone(lib_db.update_patron(mock_patron))
예제 #3
0
 def test_insert_new_patron(self):
     lib_db = Library_DB()
     pid = 1
     mock_patron = MagicMock()
     mock_patron.get_fname.return_value = "f"
     mock_patron.get_lname.return_value = ";"
     mock_patron.get_age.return_value = 21
     mock_patron.get_memberID.return_value = 5
     mock_patron.get_borrowed_books.return_value = []
     mock_db = MagicMock()
     mock_db.search.return_value = None
     mock_db.insert.return_value = pid
     lib_db.db = mock_db
     self.assertEqual(lib_db.insert_patron(mock_patron), pid)
예제 #4
0
 def test_get_all_patrons(self):
     lib_db = Library_DB()
     mock_db = MagicMock()
     mock_db.all.return_value = []
     lib_db.db = mock_db
     self.assertEquals(lib_db.get_all_patrons(), [])