Changeset 5916
- Timestamp:
- 08/17/07 09:20:25 (1 year ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/test/client.py (modified) (1 diff)
- django/trunk/docs/testing.txt (modified) (4 diffs)
- django/trunk/tests/modeltests/test_client/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r5895 r5916 285 285 Rachel Willmer <http://www.willmer.com/kb/> 286 286 Gary Wilson <gary.wilson@gmail.com> 287 Jakub Wiśniowski <restless.being@gmail.com> 287 288 wojtek 288 289 ye7cakf02@sneakemail.com django/trunk/django/test/client.py
r5741 r5916 254 254 return False 255 255 256 def logout(self): 257 """Removes the authenticated user's cookies. 258 259 Causes the authenticated user to be logged out. 260 """ 261 try: 262 Session.objects.get(session_key=self.cookies['sessionid'].value).delete() 263 except KeyError: 264 pass 265 266 self.cookies = SimpleCookie() django/trunk/docs/testing.txt
r5910 r5916 551 551 manually (using the Django model API) or with a test fixture. 552 552 553 ``logout()`` 554 **New in Django development version** 555 556 If your site uses Django's `authentication system`_, the ``logout()`` 557 method can be used to simulate the effect of a user logging out of 558 your site. 559 560 After you call this method, the test client will have all the cookies and 561 session data cleared to defaults. Subsequent requests will appear to 562 come from an AnonymousUser. 563 553 564 .. _authentication system: ../authentication/ 554 565 .. _authentication backend: ../authentication/#other-authentication-sources … … 759 770 flush the database, returning the database to the state it was in 760 771 directly after ``syncdb`` was called. 761 772 762 773 * Then, all the named fixtures are installed. In this example, Django will 763 774 install any JSON fixture named ``mammals``, followed by any fixture named … … 844 855 mail server, if you're running one.) 845 856 846 During test running, each outgoing e-mail is saved in 857 During test running, each outgoing e-mail is saved in 847 858 ``django.core.mail.outbox``. This is a simple list of all `EmailMessage`_ 848 859 instances that have been sent. It does not exist under normal execution … … 978 989 ``autoclobber`` describes the behavior that will occur if a database with 979 990 the same name as the test database is discovered: 980 991 981 992 * If ``autoclobber`` is ``False``, the user will be asked to approve 982 993 destroying the existing database. ``sys.exit`` is called if the user django/trunk/tests/modeltests/test_client/models.py
r5876 r5916 247 247 self.failIf(login) 248 248 249 def test_logout(self): 250 # Log in 251 self.client.login(username='testclient', password='password') 252 253 # Request a page that requires a login 254 response = self.client.get('/test_client/login_protected_view/') 255 self.assertEqual(response.status_code, 200) 256 self.assertEqual(response.context['user'].username, 'testclient') 257 258 # Log out 259 self.client.logout() 260 261 # Request a page that requires a login 262 response = self.client.get('/test_client/login_protected_view/') 263 self.assertRedirects(response, '/accounts/login/') 264 249 265 def test_session_modifying_view(self): 250 266 "Request a page that modifies the session"
