Exemplo 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')
Exemplo n.º 2
0
 def test_add_user(self):
     prepare_db_file()
     db = users_database.UserDataBase('udb_test.json')
     self.assertFalse(db.is_user_in_db("7"))
     usr = user.User("7", "Test", "User")
     self.assertTrue(db.add_user(usr))
     self.assertTrue(db.is_user_in_db("7"))
     remove_db_file()
Exemplo n.º 3
0
 def test_users_database_init(self):
     prepare_db_file()
     db = users_database.UserDataBase('udb_test.json')
     dic = ret_test_dic()
     for i in dic:
         self.assertEqual(db.user_dict[i].usr_id, i)
         self.assertEqual(db.user_dict[i].usr_name, dic[i]['name'])
         self.assertEqual(db.user_dict[i].usr_surname, dic[i]['surname'])
     remove_db_file()
Exemplo n.º 4
0
 def test_return_user_list(self):
     prepare_db_file()
     db = users_database.UserDataBase('udb_test.json')
     usr_list = db.return_list()
     temp_list = [
         db.user_dict["0"].usr_name + " " + db.user_dict["0"].usr_surname,
         db.user_dict["1"].usr_name + " " + db.user_dict["1"].usr_surname
     ]
     self.assertEqual(usr_list, temp_list)
     remove_db_file()
Exemplo n.º 5
0
 def test_return_max_id(self):
     prepare_db_file()
     db = users_database.UserDataBase('udb_test.json')
     self.assertEqual("1", db.get_max_id())
     remove_db_file()
Exemplo n.º 6
0
 def test_is_user_in_db(self):
     prepare_db_file()
     db = users_database.UserDataBase('udb_test.json')
     self.assertTrue(db.is_user_in_db("0"))
     self.assertFalse(db.is_user_in_db("7"))
     remove_db_file()
Exemplo n.º 7
0
 def test_users_database_init_no_db_file(self):
     remove_db_file()
     db = users_database.UserDataBase('udb_test.json')
     self.assertEqual(db.user_dict, dict())