def resource(): UserRepo.add_user(username="******", password="******", email="*****@*****.**") user_id = UserRepo.get_all_users()[0].id yield user_id drop_db("gtd_test") #TODO: Read from config?
def test_store_user(resource): UserRepo.add_user(username="******", password="******", email="*****@*****.**") users = UserRepo.get_all_users() assert len(users) == 1 assert users[0].username == "user1" assert users[0].email == "*****@*****.**" resource
def test_get_user_by_id(resource): UserRepo.add_user(username="******", password="******", email="*****@*****.**") users = UserRepo.get_all_users() assert len(users) == 1 uid = users[0].id stored_user = UserRepo.get_user_by_id(uid) assert stored_user.username == "user1" assert stored_user.email == "*****@*****.**" not_stored_user = UserRepo.get_user_by_id( random_objectid()) #should not be in the database assert not_stored_user == None resource