mirror of
https://github.com/django/django.git
synced 2025-10-27 23:56:08 +00:00
Added tests that I neglected to check in for #8049 in [12159]
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12160 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
40
tests/regressiontests/special_headers/tests.py
Normal file
40
tests/regressiontests/special_headers/tests.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class SpecialHeadersTest(TestCase):
|
||||
fixtures = ['data.xml']
|
||||
|
||||
def test_xheaders(self):
|
||||
user = User.objects.get(username='super')
|
||||
response = self.client.get('/special_headers/article/1/')
|
||||
# import pdb; pdb.set_trace()
|
||||
self.failUnless('X-Object-Type' not in response)
|
||||
self.client.login(username='super', password='secret')
|
||||
response = self.client.get('/special_headers/article/1/')
|
||||
self.failUnless('X-Object-Type' in response)
|
||||
user.is_staff = False
|
||||
user.save()
|
||||
response = self.client.get('/special_headers/article/1/')
|
||||
self.failUnless('X-Object-Type' not in response)
|
||||
user.is_staff = True
|
||||
user.is_active = False
|
||||
user.save()
|
||||
response = self.client.get('/special_headers/article/1/')
|
||||
self.failUnless('X-Object-Type' not in response)
|
||||
|
||||
def test_xview(self):
|
||||
user = User.objects.get(username='super')
|
||||
response = self.client.head('/special_headers/xview/')
|
||||
self.failUnless('X-View' not in response)
|
||||
self.client.login(username='super', password='secret')
|
||||
response = self.client.head('/special_headers/xview/')
|
||||
self.failUnless('X-View' in response)
|
||||
user.is_staff = False
|
||||
user.save()
|
||||
response = self.client.head('/special_headers/xview/')
|
||||
self.failUnless('X-View' not in response)
|
||||
user.is_staff = True
|
||||
user.is_active = False
|
||||
user.save()
|
||||
response = self.client.head('/special_headers/xview/')
|
||||
self.failUnless('X-View' not in response)
|
||||
Reference in New Issue
Block a user