author | Julien Cristau <julien.cristau@logilab.fr> |
Wed, 09 Sep 2015 09:37:14 +0200 | |
changeset 10654 | d6d9913753d2 |
parent 10651 | 9ca33768473c |
child 10960 | 9e64fddebc89 |
permissions | -rw-r--r-- |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
1 |
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5390
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6776
eebe86b89285
[tests] use TextTestRunner from unittest, no more need to use SkipAwareTextRunner from lgc.testlib (which doesn't exist anymore in recent releases
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6341
diff
changeset
|
18 |
"""unittests for cw.devtools.testlib module""" |
0 | 19 |
|
10621
987fbc88f097
[devtools/testlib] Port CubicWebTC.view() to py3k
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10620
diff
changeset
|
20 |
from io import BytesIO, StringIO |
987fbc88f097
[devtools/testlib] Port CubicWebTC.view() to py3k
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10620
diff
changeset
|
21 |
from unittest import TextTestRunner |
0 | 22 |
|
10621
987fbc88f097
[devtools/testlib] Port CubicWebTC.view() to py3k
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10620
diff
changeset
|
23 |
from six import PY2 |
9212
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
24 |
|
6776
eebe86b89285
[tests] use TextTestRunner from unittest, no more need to use SkipAwareTextRunner from lgc.testlib (which doesn't exist anymore in recent releases
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6341
diff
changeset
|
25 |
from logilab.common.testlib import TestSuite, TestCase, unittest_main |
9212
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
26 |
from logilab.common.registry import yes |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
27 |
|
0 | 28 |
from cubicweb.devtools import htmlparser |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
29 |
from cubicweb.devtools.testlib import CubicWebTC |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4473
diff
changeset
|
30 |
from cubicweb.pytestconf import clean_repo_test_cls |
0 | 31 |
|
10219
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
32 |
class FakeFormTC(TestCase): |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
33 |
def test_fake_form(self): |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
34 |
class entity: |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
35 |
cw_etype = 'Entity' |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
36 |
eid = 0 |
10620
30ebd6b2eaf3
[devtools/testlib] port 'fake_form' test to io.BytesIO
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10468
diff
changeset
|
37 |
sio = BytesIO(b'hop\n') |
10219
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
38 |
form = CubicWebTC.fake_form('import', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
39 |
{'file': ('filename.txt', sio), |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
40 |
'encoding': u'utf-8', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
41 |
}, [(entity, {'field': 'value'})]) |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
42 |
self.assertEqual(form, {'__form_id': 'import', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
43 |
'__maineid': 0, |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
44 |
'__type:0': 'Entity', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
45 |
'_cw_entity_fields:0': '__type,field', |
10468
3f27669634d2
[devtools] Sort _cw_fields in fake_form
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
46 |
'_cw_fields': 'encoding,file', |
10219
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
47 |
'eid': [0], |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
48 |
'encoding': u'utf-8', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
49 |
'field:0': 'value', |
eacb8ea38bf5
[devtools] add a method on CubicWebTC to fake data posted by standard cw forms. Closes #4985805
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9864
diff
changeset
|
50 |
'file': ('filename.txt', sio)}) |
6776
eebe86b89285
[tests] use TextTestRunner from unittest, no more need to use SkipAwareTextRunner from lgc.testlib (which doesn't exist anymore in recent releases
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6341
diff
changeset
|
51 |
|
0 | 52 |
class WebTestTC(TestCase): |
53 |
||
54 |
def setUp(self): |
|
10621
987fbc88f097
[devtools/testlib] Port CubicWebTC.view() to py3k
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10620
diff
changeset
|
55 |
output = BytesIO() if PY2 else StringIO() |
6776
eebe86b89285
[tests] use TextTestRunner from unittest, no more need to use SkipAwareTextRunner from lgc.testlib (which doesn't exist anymore in recent releases
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6341
diff
changeset
|
56 |
self.runner = TextTestRunner(stream=output) |
5390
a40ffdce549d
cleanup debugging trace
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5389
diff
changeset
|
57 |
|
0 | 58 |
def test_error_raised(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
59 |
class MyWebTest(CubicWebTC): |
0 | 60 |
|
61 |
def test_error_view(self): |
|
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
62 |
with self.admin_access.web_request() as req: |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
63 |
req.create_entity('Bug', title=u"bt") |
9864
f60a80592224
[webtests] finish to give all self.view(....) a req=req parameter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9857
diff
changeset
|
64 |
self.view('raising', req.execute('Bug B'), template=None, req=req) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
65 |
|
0 | 66 |
def test_correct_view(self): |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
67 |
with self.admin_access.web_request() as req: |
9864
f60a80592224
[webtests] finish to give all self.view(....) a req=req parameter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9857
diff
changeset
|
68 |
self.view('primary', req.execute('CWUser U'), template=None, req=req) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
69 |
|
0 | 70 |
tests = [MyWebTest('test_error_view'), MyWebTest('test_correct_view')] |
71 |
result = self.runner.run(TestSuite(tests)) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
72 |
self.assertEqual(result.testsRun, 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
73 |
self.assertEqual(len(result.errors), 0) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
74 |
self.assertEqual(len(result.failures), 1) |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4473
diff
changeset
|
75 |
clean_repo_test_cls(MyWebTest) |
0 | 76 |
|
77 |
||
78 |
HTML_PAGE = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
79 |
<html> |
|
80 |
<head><title>need a title</title></head> |
|
81 |
<body> |
|
82 |
<h1>Hello World !</h1> |
|
83 |
</body> |
|
84 |
</html> |
|
85 |
""" |
|
86 |
||
87 |
HTML_PAGE2 = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
88 |
<html> |
|
89 |
<head><title>need a title</title></head> |
|
90 |
<body> |
|
91 |
<h1>Test</h1> |
|
92 |
<h1>Hello <a href="http://www.google.com">world</a> !</h1> |
|
93 |
<h2>h2 title</h2> |
|
94 |
<h3>h3 title</h3> |
|
95 |
<h2>antoher h2 title</h2> |
|
96 |
<h4>h4 title</h4> |
|
97 |
<p><a href="http://www.logilab.org">Logilab</a> introduces CW !</p> |
|
98 |
</body> |
|
99 |
</html> |
|
100 |
""" |
|
101 |
||
102 |
HTML_PAGE_ERROR = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
103 |
<html> |
|
104 |
<head><title>need a title</title></head> |
|
105 |
<body> |
|
106 |
Logilab</a> introduces CW ! |
|
107 |
</body> |
|
108 |
</html> |
|
109 |
""" |
|
110 |
||
111 |
HTML_NON_STRICT = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
112 |
<html> |
|
113 |
<head><title>need a title</title></head> |
|
114 |
<body> |
|
115 |
<h1><a href="something.com">title</h1> |
|
116 |
</body> |
|
117 |
</html> |
|
118 |
""" |
|
119 |
||
120 |
||
121 |
class HTMLPageInfoTC(TestCase): |
|
122 |
"""test cases for PageInfo""" |
|
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
123 |
|
0 | 124 |
def setUp(self): |
8941
7b26fe71404f
drop xhtml content-type support (closes #2065651)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8694
diff
changeset
|
125 |
parser = htmlparser.HTMLValidator() |
7b26fe71404f
drop xhtml content-type support (closes #2065651)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8694
diff
changeset
|
126 |
# disable cleanup that would remove doctype |
7b26fe71404f
drop xhtml content-type support (closes #2065651)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8694
diff
changeset
|
127 |
parser.preprocess_data = lambda data: data |
0 | 128 |
self.page_info = parser.parse_string(HTML_PAGE2) |
129 |
||
130 |
def test_source1(self): |
|
131 |
"""make sure source is stored correctly""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
132 |
self.assertEqual(self.page_info.source, HTML_PAGE2) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
133 |
|
0 | 134 |
def test_source2(self): |
135 |
"""make sure source is stored correctly - raise exception""" |
|
136 |
parser = htmlparser.DTDValidator() |
|
137 |
self.assertRaises(AssertionError, parser.parse_string, HTML_PAGE_ERROR) |
|
138 |
||
139 |
def test_has_title_no_level(self): |
|
140 |
"""tests h? tags information""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
141 |
self.assertEqual(self.page_info.has_title('Test'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
142 |
self.assertEqual(self.page_info.has_title('Test '), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
143 |
self.assertEqual(self.page_info.has_title('Tes'), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
144 |
self.assertEqual(self.page_info.has_title('Hello world !'), True) |
0 | 145 |
|
146 |
def test_has_title_level(self): |
|
147 |
"""tests h? tags information""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
148 |
self.assertEqual(self.page_info.has_title('Test', level = 1), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
149 |
self.assertEqual(self.page_info.has_title('Test', level = 2), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
150 |
self.assertEqual(self.page_info.has_title('Test', level = 3), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
151 |
self.assertEqual(self.page_info.has_title('Test', level = 4), False) |
0 | 152 |
self.assertRaises(IndexError, self.page_info.has_title, 'Test', level = 5) |
153 |
||
154 |
def test_has_title_regexp_no_level(self): |
|
155 |
"""tests has_title_regexp() with no particular level specified""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
156 |
self.assertEqual(self.page_info.has_title_regexp('h[23] title'), True) |
0 | 157 |
|
158 |
def test_has_title_regexp_level(self): |
|
159 |
"""tests has_title_regexp() with a particular level specified""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
160 |
self.assertEqual(self.page_info.has_title_regexp('h[23] title', 2), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
161 |
self.assertEqual(self.page_info.has_title_regexp('h[23] title', 3), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
162 |
self.assertEqual(self.page_info.has_title_regexp('h[23] title', 4), False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
163 |
|
0 | 164 |
def test_appears(self): |
165 |
"""tests PageInfo.appears()""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
166 |
self.assertEqual(self.page_info.appears('CW'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
167 |
self.assertEqual(self.page_info.appears('Logilab'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
168 |
self.assertEqual(self.page_info.appears('Logilab introduces'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
169 |
self.assertEqual(self.page_info.appears('H2 title'), False) |
0 | 170 |
|
171 |
def test_has_link(self): |
|
172 |
"""tests has_link()""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
173 |
self.assertEqual(self.page_info.has_link('Logilab'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
174 |
self.assertEqual(self.page_info.has_link('logilab'), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
175 |
self.assertEqual(self.page_info.has_link('Logilab', 'http://www.logilab.org'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
176 |
self.assertEqual(self.page_info.has_link('Logilab', 'http://www.google.com'), False) |
0 | 177 |
|
178 |
def test_has_link_regexp(self): |
|
179 |
"""test has_link_regexp()""" |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
180 |
self.assertEqual(self.page_info.has_link_regexp('L[oi]gilab'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
181 |
self.assertEqual(self.page_info.has_link_regexp('L[ai]gilab'), False) |
0 | 182 |
|
183 |
||
8460
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
184 |
class CWUtilitiesTC(CubicWebTC): |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
185 |
|
8460
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
186 |
def test_temporary_permissions_eschema(self): |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
187 |
eschema = self.schema['CWUser'] |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
188 |
with self.temporary_permissions(CWUser={'read': ()}): |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
189 |
self.assertEqual(eschema.permissions['read'], ()) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
190 |
self.assertTrue(eschema.permissions['add']) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
191 |
self.assertTrue(eschema.permissions['read'], ()) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
192 |
|
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
193 |
def test_temporary_permissions_rdef(self): |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
194 |
rdef = self.schema['CWUser'].rdef('in_group') |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
195 |
with self.temporary_permissions((rdef, {'read': ()})): |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
196 |
self.assertEqual(rdef.permissions['read'], ()) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
197 |
self.assertTrue(rdef.permissions['add']) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
198 |
self.assertTrue(rdef.permissions['read'], ()) |
b1f6777fc839
[testlib] introduce temporary_permissions context manager
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6776
diff
changeset
|
199 |
|
10639
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
200 |
def test_temporary_permissions_rdef_with_exception(self): |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
201 |
rdef = self.schema['CWUser'].rdef('in_group') |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
202 |
try: |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
203 |
with self.temporary_permissions((rdef, {'read': ()})): |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
204 |
self.assertEqual(rdef.permissions['read'], ()) |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
205 |
self.assertTrue(rdef.permissions['add']) |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
206 |
raise ValueError('goto') |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
207 |
except ValueError: |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
208 |
self.assertTrue(rdef.permissions['read'], ()) |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
209 |
else: |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
210 |
self.fail('exception was caught unexpectedly') |
1ed205146ee2
[devtools] Fix CubicWebTC.temporary_permissions
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10219
diff
changeset
|
211 |
|
9212
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
212 |
def test_temporary_appobjects_registered(self): |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
213 |
|
9212
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
214 |
class AnAppobject(object): |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
215 |
__registries__ = ('hip',) |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
216 |
__regid__ = 'hop' |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
217 |
__select__ = yes() |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
218 |
registered = None |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
219 |
|
9212
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
220 |
@classmethod |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
221 |
def __registered__(cls, reg): |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
222 |
cls.registered = reg |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
223 |
|
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
224 |
with self.temporary_appobjects(AnAppobject): |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
225 |
self.assertEqual(self.vreg['hip'], AnAppobject.registered) |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
226 |
self.assertIn(AnAppobject, self.vreg['hip']['hop']) |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
227 |
self.assertNotIn(AnAppobject, self.vreg['hip']['hop']) |
0d346a0a1451
[testlib] temporary_appobjects should call __registered__ if it exists. Closes #3064075
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8941
diff
changeset
|
228 |
|
9472
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
229 |
def test_login(self): |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
230 |
"""Calling login should not break hook control""" |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
231 |
with self.admin_access.repo_cnx() as cnx: |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
232 |
self.hook_executed = False |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
233 |
self.create_user(cnx, 'babar') |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
234 |
cnx.commit() |
9472
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
235 |
|
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
236 |
from cubicweb.server import hook |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
237 |
from cubicweb.predicates import is_instance |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
238 |
|
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
239 |
class MyHook(hook.Hook): |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
240 |
__regid__ = 'whatever' |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
241 |
__select__ = hook.Hook.__select__ & is_instance('CWProperty') |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
242 |
category = 'test-hook' |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
243 |
events = ('after_add_entity',) |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
244 |
test = self |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
245 |
|
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
246 |
def __call__(self): |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
247 |
self.test.hook_executed = True |
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
248 |
|
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
249 |
with self.new_access('babar').repo_cnx() as cnx: |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
250 |
with self.temporary_appobjects(MyHook): |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
251 |
with cnx.allow_all_hooks_but('test-hook'): |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
252 |
prop = cnx.create_entity('CWProperty', pkey=u'ui.language', value=u'en') |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
253 |
cnx.commit() |
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
254 |
self.assertFalse(self.hook_executed) |
9472
ae97167956b1
[devtools] fix self.session._cnx vs self.cnx._cnx confusion after self.login
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
255 |
|
9402 | 256 |
|
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
257 |
class RepoAccessTC(CubicWebTC): |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
258 |
|
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
259 |
def test_repo_connection(self): |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
260 |
acc = self.new_access('admin') |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
261 |
with acc.repo_cnx() as cnx: |
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
262 |
rset = cnx.execute('Any X WHERE X is CWUser') |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
263 |
self.assertTrue(rset) |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
264 |
|
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
265 |
def test_client_connection(self): |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
266 |
acc = self.new_access('admin') |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
267 |
with acc.client_cnx() as cnx: |
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
268 |
rset = cnx.execute('Any X WHERE X is CWUser') |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
269 |
self.assertTrue(rset) |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
270 |
|
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
271 |
def test_web_request(self): |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
272 |
acc = self.new_access('admin') |
9857
618d45655865
[testlib] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9472
diff
changeset
|
273 |
with acc.web_request(elephant='babar') as req: |
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
274 |
rset = req.execute('Any X WHERE X is CWUser') |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
275 |
self.assertTrue(rset) |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
276 |
self.assertEqual('babar', req.form['elephant']) |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
277 |
|
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
278 |
def test_close(self): |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
279 |
acc = self.new_access('admin') |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
280 |
acc.close() |
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
281 |
|
9118
bb9e19df9a05
[testlib] add an default testcase.adminaccess (and use it for default session)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
9117
diff
changeset
|
282 |
def test_admin_access(self): |
bb9e19df9a05
[testlib] add an default testcase.adminaccess (and use it for default session)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
9117
diff
changeset
|
283 |
with self.admin_access.client_cnx() as cnx: |
bb9e19df9a05
[testlib] add an default testcase.adminaccess (and use it for default session)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
9117
diff
changeset
|
284 |
self.assertEqual('admin', cnx.user.login) |
bb9e19df9a05
[testlib] add an default testcase.adminaccess (and use it for default session)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
9117
diff
changeset
|
285 |
|
9117
e25c5abc667c
[testlib] introduce a RepoAccess class to easily create connection and request
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8941
diff
changeset
|
286 |
|
0 | 287 |
if __name__ == '__main__': |
288 |
unittest_main() |