Add tests for proxying WSGIRequest attributes in Request.

This commit is contained in:
Yotam Ofek 2017-11-21 18:05:16 +02:00
parent caf08867e1
commit 38b676e71a

View File

@ -249,3 +249,28 @@ class TestSecure(TestCase):
def test_default_secure_true(self):
request = Request(factory.get('/', secure=True))
assert request.scheme == 'https'
class TestWSGIRequestProxy(TestCase):
def test_access_inner_property(self):
wsgi_request = factory.get('/')
sentinel = object()
wsgi_request.__dict__['inner_property'] = sentinel
request = Request(wsgi_request)
assert request.inner_property is sentinel
def test_access_outer_property(self):
wsgi_request = factory.get('/')
inner_sentinel = object()
wsgi_request.__dict__['inner_property'] = inner_sentinel
request = Request(wsgi_request)
outer_sentinel = object()
request.__dict__['inner_property'] = outer_sentinel
assert request.inner_property is outer_sentinel