def delete(self): s = User() query = request.args try: res = s.deleteUser(query.get("id_user")) if res: return jsonify(res) return make_response(jsonify({"message": "OK"}), 200) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def put(self): query = request.get_json() try: id_ = User.updateUser(**query) if id_: res = User.search_by_id_user(id_) return make_response(jsonify({"data": res}), 201) return make_response(jsonify({"message": "ok"}), 200) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def get(self): query = request.args try: res = User.get_list_user(**query) if res: return jsonify(res) return make_response(jsonify({"message": "User not found"}), 404) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def get(self): query = request.args try: res = User.search_by_id_user(query.get("id_user")) if res: return jsonify(res) return make_response(jsonify({"message": " Not Found"}), 404) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def test_get_list(self): self.assertTrue(User.get_list_user(**User5)) self.assertTrue(User.get_list_user(**User6)) self.assertTrue(User.get_list_user(**User7)) self.assertTrue(User.get_list_user(**User8)) self.assertTrue(User.get_list_user(**User9)) self.assertTrue(User.get_list_user(**User10)) self.assertTrue(User.get_list_user(**User11))
def test_create(self): self.assertTrue(User.createUser(**User1)) self.assertTrue(User.createUser(**User2))
def test_search(self): self.assertTrue(User.search_by_id_user(3)) self.assertTrue(User.search_by_id_user(7))
def test_delete(self): self.assertTrue(User.deleteUser(1)) self.assertTrue(User.deleteUser(5))
def test_update(self): self.assertTrue(User.updateUser(**User3)) self.assertTrue(User.updateUser(**User4))
def test_create_user(self): with library_mysql.atomic() as txn: User.createUser(**User1) User.createUser(**User2) txn.rollback()
def test_get_list_user(self): with library_mysql.atomic() as txn: User.get_list_user(**User5) User.get_list_user(**User6) User.get_list_user(**User7) User.get_list_user(**User8) User.get_list_user(**User9) User.get_list_user(**User10) User.get_list_user(**User11) txn.rollback()
def test_search_user(self): with library_mysql.atomic() as txn: User.search_by_id_user(3) User.search_by_id_user(7) txn.rollback()
def test_delete_user(self): with library_mysql.atomic() as txn: User.deleteUser(1) User.deleteUser(5) txn.rollback()
def test_update_user(self): with library_mysql.atomic() as txn: User.updateUser(**User3) User.updateUser(**User4) txn.rollback()