def post(self): query = request.get_json() try: id_ = User.createUser(**query) if id_: res = User.search_by_id_user(id_) return make_response(jsonify({"data": res}), 201) return make_response(jsonify({"message": "Book not found"}), 404) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def test_create(self): self.assertTrue(User.createUser(**User1)) self.assertTrue(User.createUser(**User2))
def test_create_user(self): with library_mysql.atomic() as txn: User.createUser(**User1) User.createUser(**User2) txn.rollback()