Codebase list python-webargs / 9e952ed tests / test_djangoparser.py
9e952ed

Tree @9e952ed (Download .tar.gz)

test_djangoparser.py @9e952edraw · history · blame

import pytest
from tests.apps.django_app.base.wsgi import application

from webargs.testing import CommonTestCase


class TestDjangoParser(CommonTestCase):
    def create_app(self):
        return application

    @pytest.mark.skip(
        reason="skipping because DjangoParser does not implement handle_error"
    )
    def test_use_args_with_validation(self):
        pass

    def test_parsing_in_class_based_view(self, testapp):
        assert testapp.get("/echo_cbv?name=Fred").json == {"name": "Fred"}
        assert testapp.post_json("/echo_cbv", {"name": "Fred"}).json == {"name": "Fred"}

    def test_use_args_in_class_based_view(self, testapp):
        res = testapp.get("/echo_use_args_cbv?name=Fred")
        assert res.json == {"name": "Fred"}
        res = testapp.post_json("/echo_use_args_cbv", {"name": "Fred"})
        assert res.json == {"name": "Fred"}

    def test_use_args_in_class_based_view_with_path_param(self, testapp):
        res = testapp.get("/echo_use_args_with_path_param_cbv/42?name=Fred")
        assert res.json == {"name": "Fred"}