devtools/test/unittest_webtest.py
changeset 9930 d20c2b262f55
child 10032 fd1dafb0ab10
equal deleted inserted replaced
9929:16163ee1cdf9 9930:d20c2b262f55
       
     1 import httplib
       
     2 
       
     3 from logilab.common.testlib import Tags
       
     4 from cubicweb.devtools.webtest import CubicWebTestTC
       
     5 
       
     6 
       
     7 class CWTTC(CubicWebTestTC):
       
     8     def test_response(self):
       
     9         response = self.webapp.get('/')
       
    10         self.assertEqual(200, response.status_int)
       
    11 
       
    12     def test_base_url(self):
       
    13         if self.config['base-url'] not in self.webapp.get('/').text:
       
    14             self.fail('no mention of base url in retrieved page')
       
    15 
       
    16 
       
    17 class CWTIdentTC(CubicWebTestTC):
       
    18     anonymous_allowed = False
       
    19     tags = CubicWebTestTC.tags | Tags(('auth',))
       
    20 
       
    21     def test_reponse_denied(self):
       
    22         res = self.webapp.get('/', expect_errors=True)
       
    23         self.assertEqual(httplib.FORBIDDEN, res.status_int)
       
    24 
       
    25     def test_login(self):
       
    26         res = self.webapp.get('/', expect_errors=True)
       
    27         self.assertEqual(httplib.FORBIDDEN, res.status_int)
       
    28 
       
    29         self.login(self.admlogin, self.admpassword)
       
    30         res = self.webapp.get('/')
       
    31         self.assertEqual(httplib.OK, res.status_int)
       
    32 
       
    33         self.logout()
       
    34         res = self.webapp.get('/', expect_errors=True)
       
    35         self.assertEqual(httplib.FORBIDDEN, res.status_int)
       
    36 
       
    37 
       
    38 if __name__ == '__main__':
       
    39     from logilab.common.testlib import unittest_main
       
    40     unittest_main()