Beispiel #1
0
    def create_tours():
        print("\033[01m## Creation of tours ##\033[0m")
        make_test(lambda: TourController.create_tour(
            "First tour", "This is the first guided tour"))(
                GuidedTourTest, "all needed attributes", False)

        make_test(lambda: TourController.create_tour(
            "Second tour", "This is the second guided tour"))(
                GuidedTourTest, "all needed attributes", False)

        make_test(lambda: TourController.create_tour(
            "Third tour", "This is the third guided tour"))(
                GuidedTourTest, "all needed attributes", False)

        make_test(lambda: TourController.create_tour())(
            GuidedTourTest, "needed argument missing", True)
Beispiel #2
0
def create_guided_tour():
    name = request.form.get('name')
    description = request.form.get('description')
    if name is None or description is None:
        raise BadRequest("Parameters are missing : 'name', 'description'")

    guided_tour = TourController.create_tour(name, description)
    return ResponseCreated(guided_tour)
Beispiel #3
0
def create_guided_tour():
    name = request.args.get('name')
    description = request.args.get('description')
    if name is None or description is None:
        return 'parameter is missing', 400

    return send_response(
        lambda: TourController.create_tour(name, description))()
 def test_create_tours_3(self):
     print("all needed attributes")
     expected_response = {
         'extendedDocs': [],
         'name': 'Third tour',
         'id': 3,
         'description': 'This is the third guided tour'
     }
     assert expected_response == TourController.create_tour(
         "Third tour", "This is the third guided tour")
 def test_create_tours_1(self):
     Controller.recreate_tables()
     print("all needed attributes")
     expected_response = {
         'extendedDocs': [],
         'name': 'First tour',
         'id': 1,
         'description': 'This is the first guided tour'
     }
     assert expected_response == TourController.create_tour(
         "First tour", "This is the first guided tour")
 def test_create_tours_4(self):
     print("needed argument missing")
     with pytest.raises(IndexError):
         TourController.create_tour()