def reviews(business_id): current_user = get_jwt_identity() if request.method == 'POST': review_data = request.get_json() title = review_data.get('title') description = review_data.get('description') new_review = Reviews(title, description) new_review.add_reviews() response = {'message': 'Review Posted', 'Review by': current_user} return make_response(jsonify(response)), 201 reviews = Reviews.get_all_reviews() return make_response(jsonify(reviews)), 200
class ReivewsTestcase(unittest.TestCase): def setUp(self): Reviews.reviews = {} self.post = Reviews( "Very Tasy", "I really liked the place, its clean, nice ambience, great music") def test_add_reviews(self): #Before posting a review self.assertEqual(len(self.post.reviews), 0) self.assertEqual(self.post.review_id, 0) #After posting a review self.post.add_reviews() self.assertIsInstance(self.post, Reviews) self.assertEqual(len(self.post.reviews), 1) self.assertEqual(self.post.review_id, 1)