def tearDown(self): #delete all from users PlaceBook.delete().execute() Place.delete().execute() User.delete().execute() City.delete().execute() State.delete().execute()
def setUp(self): #connect to db and delete everyone in the users table PlaceBook.delete().execute() Place.delete().execute() User.delete().execute() City.delete().execute() State.delete().execute()
def handle_state_id(state_id): '''Select the state with the id from the database and store as the variable `state` with a GET request method. Update the data of the particular state with a PUT request method. This will take the parameters passed and update only those values. Remove the state with this id from the database with a DELETE request method. Keyword arguments: state_id: The id of the state from the database. ''' try: state = State.select().where(State.id == state_id).get() except State.DoesNotExist: return jsonify(msg="There is no state with this id."), 404 if request.method == 'GET': return jsonify(state.to_dict()), 200 elif request.method == 'DELETE': try: state = State.delete().where(State.id == state_id) except State.DoesNotExist: raise Exception("There is no state with this id.") state.execute() return jsonify(msg="State deleted successfully."), 200
def handle_state_id(state_id): '''Select the state with the id from the database and store as the variable `state` with a GET request method. Update the data of the particular state with a PUT request method. This will take the parameters passed and update only those values. Remove the state with this id from the database with a DELETE request method. Keyword arguments: state_id: The id of the state from the database. ''' try: state = State.select().where(State.id == state_id).get() except State.DoesNotExist: return jsonify(msg="There is no state with this id."), 404 if request.method == 'GET': return jsonify(state.to_dict()), 200 elif request.method == 'DELETE': try: state = State.delete().where(State.id == state_id) except State.DoesNotExist: raise Exception("There is no state with this id.") state.execute() return jsonify(msg="State deleted successfully."), 200
def del_state(id): id_check = State.select().where(State.id == id) if not id_check: return {'code': 404, 'msg': 'State not found'}, 404 item = State.delete().where(State.id == id) item.execute() return {'code': 200, 'msg': 'Deleted successfully'}, 200
def delete_state(state_id): """ Delete state with id as state_id """ try: state = State.get(State.id == state_id) except Exception as error: response = {} response['code'] = 404 response['msg'] = 'State not found' return response, 404 delete_state = State.delete().where(State.id == state_id) delete_state.execute() response = {} response['code'] = 200 response['msg'] = "State was deleted successfully" return response, 200
def delete_state(state_id): """ Delete the given state Deletes the given state in the database. --- tags: - State parameters: - in: path name: state_id type: string required: True description: ID of the state responses: 200: description: State deleted successfully schema: $ref: '#/definitions/delete_amenity_delete_delete_200' 404: description: State was not found 500: description: Request could not be processed """ try: ''' Check that state_id exists ''' query = State.select().where(State.id == state_id) if not query.exists(): raise LookupError('state_id') ''' Delete the given state ''' delete_state = State.delete().where(State.id == state_id) delete_state.execute() response = {} response['code'] = 200 response['msg'] = "State account was deleted" return response, 200 except LookupError as e: abort(404) except Exception as error: abort(500)
def setUp(self): #connect to db and delete everyone in the cities table City.delete().execute() State.delete().execute()
def tearDown(self): #delete all from cities City.delete().execute() State.delete().execute()
def setUp(self): #connect to db and delete everyone in the states table State.delete().execute()
def tearDown(self): #delete all from states State.delete().execute()
def tearDown(self): #delete all from places Place.delete().execute() User.delete().execute() City.delete().execute() State.delete().execute()