mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 13:04:03 +03:00
Add test
This commit is contained in:
parent
85c96bb574
commit
dbd057b9a9
|
@ -224,7 +224,8 @@ class TestUserSetter(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Pass request object through session middleware so session is
|
# Pass request object through session middleware so session is
|
||||||
# available to login and logout functions
|
# available to login and logout functions
|
||||||
self.request = Request(factory.get('/'))
|
self.wrapped_request = factory.get('/')
|
||||||
|
self.request = Request(self.wrapped_request)
|
||||||
SessionMiddleware().process_request(self.request)
|
SessionMiddleware().process_request(self.request)
|
||||||
|
|
||||||
User.objects.create_user('ringo', 'starr@thebeatles.com', 'yellow')
|
User.objects.create_user('ringo', 'starr@thebeatles.com', 'yellow')
|
||||||
|
@ -244,6 +245,10 @@ class TestUserSetter(TestCase):
|
||||||
logout(self.request)
|
logout(self.request)
|
||||||
self.assertTrue(self.request.user.is_anonymous())
|
self.assertTrue(self.request.user.is_anonymous())
|
||||||
|
|
||||||
|
def test_logged_in_user_is_set_on_wrapped_request(self):
|
||||||
|
login(self.request, self.user)
|
||||||
|
self.assertEqual(self.wrapped_request.user, self.user)
|
||||||
|
|
||||||
|
|
||||||
class TestAuthSetter(TestCase):
|
class TestAuthSetter(TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user