11 |
11 |
12 from logilab.common.debugger import Debugger |
12 from logilab.common.debugger import Debugger |
13 from logilab.common.testlib import InnerTest |
13 from logilab.common.testlib import InnerTest |
14 from logilab.common.pytest import nocoverage |
14 from logilab.common.pytest import nocoverage |
15 |
15 |
16 from rql import parse |
|
17 |
|
18 from cubicweb.devtools import VIEW_VALIDATORS |
16 from cubicweb.devtools import VIEW_VALIDATORS |
19 from cubicweb.devtools.apptest import EnvBasedTC |
17 from cubicweb.devtools.apptest import EnvBasedTC |
20 from cubicweb.devtools._apptest import unprotected_entities, SYSTEM_RELATIONS |
18 from cubicweb.devtools._apptest import unprotected_entities, SYSTEM_RELATIONS |
21 from cubicweb.devtools.htmlparser import DTDValidator, SaxOnlyValidator, HTMLValidator |
19 from cubicweb.devtools.htmlparser import DTDValidator, SaxOnlyValidator, HTMLValidator |
22 from cubicweb.devtools.fill import insert_entity_queries, make_relations_queries |
20 from cubicweb.devtools.fill import insert_entity_queries, make_relations_queries |
23 |
21 |
24 from cubicweb.sobjects.notification import NotificationView |
22 from cubicweb.sobjects.notification import NotificationView |
25 |
23 |
26 from cubicweb.vregistry import NoSelectableObject |
24 from cubicweb.vregistry import NoSelectableObject |
27 from cubicweb.web.action import Action |
|
28 from cubicweb.web.views.basetemplates import TheMainTemplate |
|
29 |
25 |
30 |
26 |
31 ## TODO ############### |
27 ## TODO ############### |
32 # creation tests: make sure an entity was actually created |
28 # creation tests: make sure an entity was actually created |
33 # Existing Test Environment |
29 # Existing Test Environment |
147 ignored_relations = SYSTEM_RELATIONS + self.ignored_relations |
143 ignored_relations = SYSTEM_RELATIONS + self.ignored_relations |
148 for rschema in self.schema.relations(): |
144 for rschema in self.schema.relations(): |
149 if rschema.is_final() or rschema in ignored_relations: |
145 if rschema.is_final() or rschema in ignored_relations: |
150 continue |
146 continue |
151 rset = cu.execute('DISTINCT Any X,Y WHERE X %s Y' % rschema) |
147 rset = cu.execute('DISTINCT Any X,Y WHERE X %s Y' % rschema) |
152 existingrels.setdefault(rschema.type, set()).update((x,y) for x, y in rset) |
148 existingrels.setdefault(rschema.type, set()).update((x, y) for x, y in rset) |
153 q = make_relations_queries(self.schema, edict, cu, ignored_relations, |
149 q = make_relations_queries(self.schema, edict, cu, ignored_relations, |
154 existingrels=existingrels) |
150 existingrels=existingrels) |
155 for rql, args in q: |
151 for rql, args in q: |
156 cu.execute(rql, args) |
152 cu.execute(rql, args) |
157 self.post_populate(cu) |
153 self.post_populate(cu) |
327 rset.req.reset_headers(), 'main-template') |
323 rset.req.reset_headers(), 'main-template') |
328 # We have to do this because some views modify the |
324 # We have to do this because some views modify the |
329 # resultset's syntax tree |
325 # resultset's syntax tree |
330 rset = backup_rset |
326 rset = backup_rset |
331 for action in self.list_actions_for(rset): |
327 for action in self.list_actions_for(rset): |
332 # XXX this seems a bit dummy |
|
333 #yield InnerTest(self._testname(rset, action.id, 'action'), |
|
334 # self.failUnless, |
|
335 # isinstance(action, Action)) |
|
336 yield InnerTest(self._testname(rset, action.id, 'action'), action.url) |
328 yield InnerTest(self._testname(rset, action.id, 'action'), action.url) |
337 for box in self.list_boxes_for(rset): |
329 for box in self.list_boxes_for(rset): |
338 yield InnerTest(self._testname(rset, box.id, 'box'), box.dispatch) |
330 yield InnerTest(self._testname(rset, box.id, 'box'), box.dispatch) |
339 |
331 |
340 @staticmethod |
332 @staticmethod |