def reset(self): for _id in self.created_ids: review = Review.get_by_id(_id) review.delete() self.user.delete() self.business.delete()
def reset(self): """ clean up any remaining test users """ for _id in self.created_ids: review = Review.get_by_id(_id) if review: review.delete() self.user.delete() self.business.delete()
def review_get(request): """ Returns the business review errors ====== * status 404 - if the review couldn't be found returns ======= :: { "rating": 5, "modified": "2015-08-10T00:20:17.753000", "id": "55c7ee41fad9b43993d71919", "user_id": "55c7ee3dfad9b43993d7190e", "reviewed_id": "55c7ee3efad9b43993d7190f", "tags": [ "awesome" ], "text": "This is awesome.", "created": "2015-08-10T00:20:17.753000", "reviewed_collection": "businesses" } """ business_id = request.matchdict['business_id'] review_id = request.matchdict['review_id'] business = Business.get_by_id(business_id) review = Review.get_by_id(review_id) if business and review and business.id == review.reviewed_id: response_body = review.json logger.debug('Retrieved business:{} review:{}'.format(business.id, review.id)) else: logger.debug('Failed to retrieve business:{} review:'.format(business_id, review_id)) request.response.status_int = 404 response_body = json.dumps({ 'status': 'error', 'message': 'failed to find business review' }) request.response.body = response_body request.response.content_type = 'application/json' return request.response