Ejemplo n.º 1
0
 def __init__(self):
     self.book_category_database = bcb.BookCategoryDataBase(
         'book_category_db.json')
     self.user_database = ub.UserDataBase('users_db.json')
     self.author_database = ab.AuthorDataBase('author_db.json')
     self.book_database = bb.BookDataBase('book_db.json')
     self.history = self.load_history('history.json')
Ejemplo n.º 2
0
 def test_add_author(self):
     prepare_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     self.assertFalse(db.is_author_in_db("7"))
     aut = author.Author("7", "Test", "User")
     self.assertTrue(db.add_author(aut))
     self.assertTrue(db.is_author_in_db("7"))
     remove_db_file()
Ejemplo n.º 3
0
 def test_author_database_init(self):
     prepare_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     dic = ret_test_dic()
     for i in dic:
         self.assertEqual(db.author_dict[i].uid, i)
         self.assertEqual(db.author_dict[i].aut_name, dic[i]['name'])
         self.assertEqual(db.author_dict[i].aut_surname, dic[i]['surname'])
     remove_db_file()
Ejemplo n.º 4
0
 def test_return_author_list(self):
     prepare_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     aut_list = db.return_list()
     temp_list = [
         db.author_dict["0"].aut_name + " " +
         db.author_dict["0"].aut_surname, db.author_dict["1"].aut_name +
         " " + db.author_dict["1"].aut_surname
     ]
     self.assertEqual(aut_list, temp_list)
     remove_db_file()
Ejemplo n.º 5
0
 def test_return_max_id(self):
     prepare_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     self.assertEqual("1", db.get_max_id())
     remove_db_file()
Ejemplo n.º 6
0
 def test_is_author_in_db(self):
     prepare_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     self.assertTrue(db.is_author_in_db("0"))
     self.assertFalse(db.is_author_in_db("7"))
     remove_db_file()
Ejemplo n.º 7
0
 def test_author_database_init_no_db_file(self):
     remove_db_file()
     db = author_database.AuthorDataBase('adb_test.json')
     self.assertEqual(db.author_dict, dict())