mirror of
https://github.com/django/django.git
synced 2025-11-03 05:13:23 +00:00
Added a `session` attribute to the test Client, to make it easier to test if session variables have been modified in a view. Also renamed Client.cookie to Client.cookies, to match documentation and common sense.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4464 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4ccdf127d0
commit
9ba27afce0
5 changed files with 67 additions and 9 deletions
|
|
@ -99,3 +99,19 @@ class ClientTest(unittest.TestCase):
|
|||
|
||||
response = self.client.login('/test_client/login_protected_view/', 'otheruser', 'nopassword')
|
||||
self.assertFalse(response)
|
||||
|
||||
def test_session_modifying_view(self):
|
||||
"Request a page that modifies the session"
|
||||
# Session value isn't set initially
|
||||
try:
|
||||
self.client.session['tobacconist']
|
||||
self.fail("Shouldn't have a session value")
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
from django.contrib.sessions.models import Session
|
||||
response = self.client.post('/test_client/session_view/')
|
||||
|
||||
# Check that the session was modified
|
||||
self.assertEquals(self.client.session['tobacconist'], 'hovercraft')
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue