How to use the tavern._plugins.rest.request.get_request_args function in tavern

To help you get started, we’ve selected a few tavern examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_headers_no_content_type_change(self, req, includes, extra_headers):
        """Sending a file doesn't set the content type as json"""
        del req["data"]
        req["files"] = ["abc"]

        args = get_request_args(req, includes)

        assert "content-type" not in [i.lower() for i in args["headers"].keys()]
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_nested_params_encoded(self, req, includes):
        req["params"] = {"a": {"b": {"c": "d"}}}

        args = get_request_args(req, includes)

        assert args["params"]["a"] == "%7B%22b%22%3A+%7B%22c%22%3A+%22d%22%7D%7D"
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_array_substitution(self, req, includes):
        args = get_request_args(req, includes)

        assert args["data"]["array"] == ["def456", "def456"]
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_file_and_json_fails(self, req, includes):
        """Can't send json and files at once"""
        req["files"] = ["abc"]
        req["json"] = {"key": "value"}

        with pytest.raises(exceptions.BadSchemaError):
            get_request_args(req, includes)
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_file_and_data_succeeds(self, req, includes):
        """Can send form data and files at once"""
        req["files"] = ["abc"]

        get_request_args(req, includes)
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_no_override_method(self, req, includes):
        req["method"] = "POST"

        args = get_request_args(req, includes)

        assert args["method"] == "POST"
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_default_method_raises_with_body(self, req, includes, body_key):
        del req["method"]
        del req["data"]

        req[body_key] = {"a": "b"}

        with pytest.warns(RuntimeWarning):
            get_request_args(req, includes)
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_no_default_content_type(self, req, includes, extra):
        del req["headers"]["Content-Type"]
        req.pop("json", {})
        req.pop("data", {})

        req.update(**extra)

        args = get_request_args(req, includes)

        # Requests will automatically set content type headers for json/form encoded data so we don't need to
        with pytest.raises(KeyError):
            assert args["headers"]["content-type"]
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_no_override_content_type_case_insensitive(self, req, includes):
        del req["headers"]["Content-Type"]
        req["headers"]["content-type"] = "application/x-www-form-urlencoded"

        args = get_request_args(req, includes)

        assert args["headers"]["content-type"] == "application/x-www-form-urlencoded"
github taverntesting / tavern / tests / unit / test_request.py View on Github external
def test_no_set_content_type(self, req, includes):
        del req["headers"]["Content-Type"]

        args = get_request_args(req, includes)

        with pytest.raises(KeyError):
            assert args["headers"]["content-type"]