def test_return_book_category_list(self): prepare_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') bc_list = db.return_list() temp_list = [db.book_cat_dict["0"].name, db.book_cat_dict["1"].name] self.assertEqual(bc_list, temp_list) remove_db_file()
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')
def test_add_book_category(self): prepare_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') self.assertFalse(db.is_book_cat_in_db("7")) bc = book_category.BookCategory("Test", "7") self.assertTrue(db.add_book_cat(bc)) self.assertTrue(db.is_book_cat_in_db("7")) remove_db_file()
def test_book_category_database_init(self): prepare_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') dic = ret_test_dic() for i in dic: self.assertEqual(db.book_cat_dict[i].id, i) self.assertEqual(db.book_cat_dict[i].name, dic[i]['name']) remove_db_file()
def test_return_max_id(self): prepare_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') self.assertEqual("1", db.get_max_id()) remove_db_file()
def test_is_book_category_in_db(self): prepare_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') self.assertTrue(db.is_book_cat_in_db("0")) self.assertFalse(db.is_book_cat_in_db("7")) remove_db_file()
def test_book_category_database_init_no_db_file(self): remove_db_file() db = book_category_database.BookCategoryDataBase('bcdb_test.json') self.assertEqual(db.book_cat_dict, dict())