Added setter to the auth property

This commit is contained in:
Mark Hughes 2012-12-20 23:48:10 +00:00
parent c27295dcbd
commit 125f027d2d
2 changed files with 16 additions and 0 deletions

View File

@ -188,6 +188,14 @@ class Request(object):
self._user, self._auth = self._authenticate()
return self._auth
@auth.setter
def auth(self, value):
"""
Sets any non-user authentication information associated with the
request, such as an authentication token.
"""
self._auth = value
def _load_data_and_files(self):
"""
Parses the request content into self.DATA and self.FILES.

View File

@ -303,3 +303,11 @@ class TestUserSetter(TestCase):
self.assertFalse(self.request.user.is_anonymous())
logout(self.request)
self.assertTrue(self.request.user.is_anonymous())
class TestAuthSetter(TestCase):
def test_auth_can_be_set(self):
request = Request(factory.get('/'))
request.auth = 'DUMMY'
self.assertEqual(request.auth, 'DUMMY')