parts/django/tests/regressiontests/special_headers/tests.py
changeset 307 c6bca38c1cbf
equal deleted inserted replaced
306:5ff1fc726848 307:c6bca38c1cbf
       
     1 from django.test import TestCase
       
     2 from django.contrib.auth.models import User
       
     3 
       
     4 class SpecialHeadersTest(TestCase):
       
     5     fixtures = ['data.xml']
       
     6 
       
     7     def test_xheaders(self):
       
     8         user = User.objects.get(username='super')
       
     9         response = self.client.get('/special_headers/article/1/')
       
    10         # import pdb; pdb.set_trace()
       
    11         self.failUnless('X-Object-Type' not in response)
       
    12         self.client.login(username='super', password='secret')
       
    13         response = self.client.get('/special_headers/article/1/')
       
    14         self.failUnless('X-Object-Type' in response)
       
    15         user.is_staff = False
       
    16         user.save()
       
    17         response = self.client.get('/special_headers/article/1/')
       
    18         self.failUnless('X-Object-Type' not in response)
       
    19         user.is_staff = True
       
    20         user.is_active = False
       
    21         user.save()
       
    22         response = self.client.get('/special_headers/article/1/')
       
    23         self.failUnless('X-Object-Type' not in response)
       
    24 
       
    25     def test_xview(self):
       
    26         user = User.objects.get(username='super')
       
    27         response = self.client.head('/special_headers/xview/')
       
    28         self.failUnless('X-View' not in response)
       
    29         self.client.login(username='super', password='secret')
       
    30         response = self.client.head('/special_headers/xview/')
       
    31         self.failUnless('X-View' in response)
       
    32         user.is_staff = False
       
    33         user.save()
       
    34         response = self.client.head('/special_headers/xview/')
       
    35         self.failUnless('X-View' not in response)
       
    36         user.is_staff = True
       
    37         user.is_active = False
       
    38         user.save()
       
    39         response = self.client.head('/special_headers/xview/')
       
    40         self.failUnless('X-View' not in response)