|
1 from six.moves import http_client |
|
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 test_db_id = 'webtest-ident' |
|
19 anonymous_allowed = False |
|
20 tags = CubicWebTestTC.tags | Tags(('auth',)) |
|
21 |
|
22 def test_reponse_denied(self): |
|
23 res = self.webapp.get('/', expect_errors=True) |
|
24 self.assertEqual(http_client.FORBIDDEN, res.status_int) |
|
25 |
|
26 def test_login(self): |
|
27 res = self.webapp.get('/', expect_errors=True) |
|
28 self.assertEqual(http_client.FORBIDDEN, res.status_int) |
|
29 |
|
30 self.login(self.admlogin, self.admpassword) |
|
31 res = self.webapp.get('/') |
|
32 self.assertEqual(http_client.OK, res.status_int) |
|
33 |
|
34 self.logout() |
|
35 res = self.webapp.get('/', expect_errors=True) |
|
36 self.assertEqual(http_client.FORBIDDEN, res.status_int) |
|
37 |
|
38 |
|
39 if __name__ == '__main__': |
|
40 from logilab.common.testlib import unittest_main |
|
41 unittest_main() |