def read_tours(): print("\n\033[01m## Reading ##\033[0m") make_test(lambda: TourController.get_tours())(GuidedTourTest, "all tours", False) # @TODO: create method to filter docs make_test(lambda: TourController.get_tours())(GuidedTourTest, "specific tour", False) make_test(lambda: TourController.get_tour_by_id(2))( GuidedTourTest, "tour with existing id", False) make_test(lambda: TourController.get_tour_by_id(-1))( GuidedTourTest, "tour with non existing id", True)
def test_read_tours_2(self): print("tour with existing id") expected_response = { 'extendedDocs': [], 'name': 'First tour', 'id': 1, 'description': 'This is the first guided tour' } assert expected_response == TourController.get_tour_by_id(1)
def test_read_tours_3(self): print("tour with non existing id") with pytest.raises(sqlalchemy.orm.exc.NoResultFound): TourController.get_tour_by_id(-1)
def get_guided_tour(tour_id): guided_tour = TourController.get_tour_by_id(tour_id) return ResponseOK(guided_tour)
def get_guided_tour(tour_id): return send_response(lambda: TourController.get_tour_by_id(tour_id))()