def test_request_model_does_not_find_row_if_it_does_not_exist(initialize_db): """ Tests that model does not find row correctly if it does not exist in the db. Args: initialize_db (None): initializes the database and drops tables when test function finishes. """ with raises(ClientError) as err: Request.find_by_id(1) assert err.value.message == 'cannot find specified request' assert err.value.status_code == 404
def test_request_model_updates_correctly_if_it_exists(valid_request_model): """ Tests that model __repr__ row correctly. Args: valid_request_model (Model): a valid model created by a fixture. """ valid_request_model.update(title="Restruture customer care") updated_request = Request.find_by_id(1) assert updated_request.title == 'Restruture customer care'
def test_request_model_finds_row_if_it_exists(valid_request_model): """ Tests that model finds row correctly if it exists in the db. Args: valid_request_model (Model): a valid model created by a fixture. """ request = Request.find_by_id(1) assert request.title == 'Improve customer care services' assert request.staff_id == 1 assert request.product_area == ProductArea.POLICIES
def get(self, request_id): """ Gets a specific request feature request and associated comments. """ # Get the requested request request = Request.find_by_id(request_id) # Create a serialization schema request_schema = RequestSchema(exclude=('updated_at')) return { 'success': True, 'message': messages['fetched']('request'), 'data': request_schema.serialize(request) }
def get(self, request_id): """ Gets all the comments under a request. """ # Get the requested comment comments = Request.find_by_id(request_id).comments # Create a serialization schema comments_schema = CommentSchema(exclude=('updated_at'), many=True) return { 'success': True, 'message': messages['fetched']('comments'), 'data': comments_schema.serialize(comments) }