Esempio n. 1
0
    def test_resource_with_custom_ident(self):
        app = Flask(__name__)
        add_resource(app, Cartoon, ident="nickname")

        assert_allowed_methods("/cartoon", ["GET", "POST"], app)
        assert_allowed_methods("/cartoon/coyote", ["GET", "DELETE", "PATCH"],
                               app)
Esempio n. 2
0
    def test_custom_base_url(self):
        app = Flask(__name__)
        add_resource(app, Cartoon, "animations")

        assert_allowed_methods("/animations", ["GET", "POST"], app)
        assert_allowed_methods("/animations/1", ["GET", "DELETE", "PATCH"],
                               app)
Esempio n. 3
0
    def test_resource_with_composite_ident(self):
        app = Flask(__name__)
        add_resource(app, OrderLine)

        assert_allowed_methods("/order-line", ["GET", "POST"], app)
        assert_allowed_methods("/order-line/3,14", ["GET", "DELETE", "PATCH"],
                               app)
Esempio n. 4
0
    def test_path_implementing_only_listed_methods(self):
        app = Flask(__name__)

        @app.route("/candies", methods=["PATCH", "PUT"])
        def candies():
            pass

        assert_allowed_methods("/candies", ["PATCH", "PUT"], app)
Esempio n. 5
0
    def test_path_not_allowing_listed_methods(self):
        app = Flask(__name__)

        @app.route("/candies", methods=["GET"])
        def candies():
            pass

        message = "The path `/candies` does not implement the method POST"

        with pytest.raises(AssertionError, match=message):
            assert_allowed_methods("/candies", ["GET", "POST"], app)
Esempio n. 6
0
    def test_path_allowing_unlisted_methods(self):
        app = Flask(__name__)

        @app.route("/candies", methods=["GET", "POST", "DELETE"])
        def candies():
            pass

        message = "The path `/candies` should not allow the method DELETE"

        with pytest.raises(AssertionError, match=message):
            assert_allowed_methods("/candies", ["GET", "POST"], app)
Esempio n. 7
0
    def test_exclude_http_methods(self):
        app = Flask(__name__)
        add_resource(app,
                     Cartoon,
                     methods={
                         "list": ["GET"],
                         "item": ["GET", "PATCH"]
                     })

        assert_allowed_methods("/cartoon", ["GET"], app)
        assert_allowed_methods("/cartoon/1", ["GET", "PATCH"], app)
Esempio n. 8
0
    def test_non_existent_path(self):
        app = Flask(__name__)

        with pytest.raises(NotFound):
            assert_allowed_methods("/unknown", ["GET"], app)
Esempio n. 9
0
    def test_add_organization_resource(self, app):
        add_resource(app, Todo, "todos")

        assert_allowed_methods("/orgs/acme/todos", ["GET", "POST"], app)
        assert_allowed_methods("/orgs/acme/todos/1",
                               ["GET", "DELETE", "PATCH"], app)
Esempio n. 10
0
    def test_basic_usage(self):
        app = Flask(__name__)
        add_resource(app, Cartoon)

        assert_allowed_methods("/cartoon", ["GET", "POST"], app)
        assert_allowed_methods("/cartoon/1", ["GET", "DELETE", "PATCH"], app)
Esempio n. 11
0
 def test_allowed_methods(self, app):
     assert_allowed_methods("/orgs/acme/roles", ["GET", "POST"], app)
     assert_allowed_methods("/orgs/acme/roles/1", ["GET", "PATCH", "DELETE"], app)
Esempio n. 12
0
 def test_allowed_methods(self, app):
     assert_allowed_methods("/abilities", ["GET"], app)
     assert_allowed_methods("/abilities/1,1", ["GET"], app)
Esempio n. 13
0
 def test_allowed_methods(self, app):
     assert_allowed_methods("/actions", ["GET"], app)
     assert_allowed_methods("/actions/1", ["GET"], app)
Esempio n. 14
0
 def test_allowed_methods(self, app):
     assert_allowed_methods("/resources", ["GET"], app)
     assert_allowed_methods("/resources/1", ["GET"], app)
Esempio n. 15
0
def test_allowed_methods(app):
    assert_allowed_methods("/signup", ["POST"], app)