821 for box in self.vreg['ctxcomponents'].possible_objects(req, rset=rset): |
821 for box in self.vreg['ctxcomponents'].possible_objects(req, rset=rset): |
822 yield box |
822 yield box |
823 |
823 |
824 def list_startup_views(self): |
824 def list_startup_views(self): |
825 """returns the list of startup views""" |
825 """returns the list of startup views""" |
826 req = self.request() |
826 with self.admin_access.web_request() as req: |
827 for view in self.vreg['views'].possible_views(req, None): |
827 for view in self.vreg['views'].possible_views(req, None): |
828 if view.category == 'startupview': |
828 if view.category == 'startupview': |
829 yield view.__regid__ |
829 yield view.__regid__ |
830 else: |
830 else: |
831 not_selected(self.vreg, view) |
831 not_selected(self.vreg, view) |
|
832 |
832 |
833 |
833 # web ui testing utilities ################################################# |
834 # web ui testing utilities ################################################# |
834 |
835 |
835 @property |
836 @property |
836 @cached |
837 @cached |
1295 self.post_populate(cu) |
1296 self.post_populate(cu) |
1296 self.commit() |
1297 self.commit() |
1297 |
1298 |
1298 def iter_individual_rsets(self, etypes=None, limit=None): |
1299 def iter_individual_rsets(self, etypes=None, limit=None): |
1299 etypes = etypes or self.to_test_etypes() |
1300 etypes = etypes or self.to_test_etypes() |
1300 for etype in etypes: |
1301 with self.admin_access.web_request() as req: |
1301 if limit: |
1302 for etype in etypes: |
1302 rql = 'Any X LIMIT %s WHERE X is %s' % (limit, etype) |
1303 if limit: |
1303 else: |
1304 rql = 'Any X LIMIT %s WHERE X is %s' % (limit, etype) |
1304 rql = 'Any X WHERE X is %s' % etype |
1305 else: |
1305 rset = self.execute(rql) |
1306 rql = 'Any X WHERE X is %s' % etype |
1306 for row in xrange(len(rset)): |
1307 rset = req.execute(rql) |
1307 if limit and row > limit: |
1308 for row in xrange(len(rset)): |
1308 break |
1309 if limit and row > limit: |
1309 # XXX iirk |
1310 break |
1310 rset2 = rset.limit(limit=1, offset=row) |
1311 # XXX iirk |
1311 yield rset2 |
1312 rset2 = rset.limit(limit=1, offset=row) |
|
1313 yield rset2 |
1312 |
1314 |
1313 def iter_automatic_rsets(self, limit=10): |
1315 def iter_automatic_rsets(self, limit=10): |
1314 """generates basic resultsets for each entity type""" |
1316 """generates basic resultsets for each entity type""" |
1315 etypes = self.to_test_etypes() |
1317 etypes = self.to_test_etypes() |
1316 if not etypes: |
1318 if not etypes: |
1317 return |
1319 return |
1318 for etype in etypes: |
1320 with self.admin_access.web_request() as req: |
1319 yield self.execute('Any X LIMIT %s WHERE X is %s' % (limit, etype)) |
1321 for etype in etypes: |
1320 etype1 = etypes.pop() |
1322 yield req.execute('Any X LIMIT %s WHERE X is %s' % (limit, etype)) |
1321 try: |
1323 etype1 = etypes.pop() |
1322 etype2 = etypes.pop() |
1324 try: |
1323 except KeyError: |
1325 etype2 = etypes.pop() |
1324 etype2 = etype1 |
1326 except KeyError: |
1325 # test a mixed query (DISTINCT/GROUP to avoid getting duplicate |
1327 etype2 = etype1 |
1326 # X which make muledit view failing for instance (html validation fails |
1328 # test a mixed query (DISTINCT/GROUP to avoid getting duplicate |
1327 # because of some duplicate "id" attributes) |
1329 # X which make muledit view failing for instance (html validation fails |
1328 yield self.execute('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is %s, Y is %s' % (etype1, etype2)) |
1330 # because of some duplicate "id" attributes) |
1329 # test some application-specific queries if defined |
1331 yield req.execute('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is %s, Y is %s' % (etype1, etype2)) |
1330 for rql in self.application_rql: |
1332 # test some application-specific queries if defined |
1331 yield self.execute(rql) |
1333 for rql in self.application_rql: |
|
1334 yield req.execute(rql) |
1332 |
1335 |
1333 def _test_everything_for(self, rset): |
1336 def _test_everything_for(self, rset): |
1334 """this method tries to find everything that can be tested |
1337 """this method tries to find everything that can be tested |
1335 for `rset` and yields a callable test (as needed in generative tests) |
1338 for `rset` and yields a callable test (as needed in generative tests) |
1336 """ |
1339 """ |
1388 yield testargs |
1391 yield testargs |
1389 |
1392 |
1390 ## startup views |
1393 ## startup views |
1391 def test_startup_views(self): |
1394 def test_startup_views(self): |
1392 for vid in self.list_startup_views(): |
1395 for vid in self.list_startup_views(): |
1393 req = self.request() |
1396 with self.admin_access.web_request() as req: |
1394 yield self.view, vid, None, req |
1397 yield self.view, vid, None, req |
1395 |
1398 |
1396 |
1399 |
1397 # registry instrumentization ################################################### |
1400 # registry instrumentization ################################################### |
1398 |
1401 |
1399 def not_selected(vreg, appobject): |
1402 def not_selected(vreg, appobject): |