Пример #1
0
    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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
def get_guided_tour(tour_id):
    guided_tour = TourController.get_tour_by_id(tour_id)
    return ResponseOK(guided_tour)
Пример #5
0
def get_guided_tour(tour_id):
    return send_response(lambda: TourController.get_tour_by_id(tour_id))()