# HG changeset patch # User Sylvain Thénault # Date 1298020708 -3600 # Node ID cd2ea273007ada726df502638119eff03f0a3945 # Parent 6665fa16aa4542b2670439c63316537d1114930a [web test] fix some tests broken by recent (and various) changesets notice test_jscript and test_windmill are still broken, a pain to maintain and so breaks apycot test since we can't see state change from green to red (they are always red due to those two tests) diff -r 6665fa16aa45 -r cd2ea273007a web/test/jstests/test_ajax.js --- a/web/test/jstests/test_ajax.js Fri Feb 18 09:33:51 2011 +0100 +++ b/web/test/jstests/test_ajax.js Fri Feb 18 10:18:28 2011 +0100 @@ -44,7 +44,7 @@ callback: function() { var origLength = scriptsIncluded.length; scriptsIncluded = jsSources(); - // check that foo.js has been inserted in + // check that foo.js has been *appended* to equals(scriptsIncluded.length, origLength + 1); equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0); // check that
has been removed @@ -105,7 +105,7 @@ test('test callback after synchronous request with parameters', function() { var deferred = new Deferred(); var result = jQuery.ajax({ - url: './ajax_url0.html', + url: '/../ajax_url0.html', async: false, beforeSend: function(xhr) { deferred._req = xhr; diff -r 6665fa16aa45 -r cd2ea273007a web/test/unittest_form.py --- a/web/test/unittest_form.py Fri Feb 18 09:33:51 2011 +0100 +++ b/web/test/unittest_form.py Fri Feb 18 10:18:28 2011 +0100 @@ -92,9 +92,15 @@ form.content_type = 'text/html' pageinfo = self._check_html(form.render(), form, template=None) inputs = pageinfo.find_tag('select', False) - self.failUnless(any(attrs for t, attrs in inputs if attrs.get('name') == 'in_group-subject:A')) + ok = False + for selectnode in pageinfo.matching_nodes('select', name='from_in_group-subject:A'): + for optionnode in selectnode: + self.assertEqual(optionnode.get('value'), str(geid)) + self.assertEqual(ok, False) + ok = True + self.assertEqual(ok, True, 'expected option not found') inputs = pageinfo.find_tag('input', False) - self.failIf(any(attrs for t, attrs in inputs if attrs.get('name') == '__linkto')) + self.failIf(list(pageinfo.matching_nodes('input', name='__linkto'))) def test_reledit_composite_field(self): rset = self.execute('INSERT BlogEntry X: X title "cubicweb.org", X content "hop"') diff -r 6665fa16aa45 -r cd2ea273007a web/test/unittest_urlpublisher.py --- a/web/test/unittest_urlpublisher.py Fri Feb 18 09:33:51 2011 +0100 +++ b/web/test/unittest_urlpublisher.py Fri Feb 18 10:18:28 2011 +0100 @@ -56,41 +56,50 @@ self.assertRaises(NotFound, self.process, '123/345') self.assertRaises(NotFound, self.process, 'not_eid') - def test_rest_path(self): + def test_rest_path_etype(self): """tests the rest path resolution""" - ctrl, rset = self.process('CWUser') + ctrl, rset = self.process('CWEType') self.assertEqual(ctrl, 'view') - self.assertEqual(rset.description[0][0], 'CWUser') + self.assertEqual(rset.description[0][0], 'CWEType') self.assertEqual(rset.printable_rql(), - "Any X,AA,AB,AC,AD ORDERBY AA WHERE X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD") + "Any X,AA,AB ORDERBY AA WHERE X is CWEType, X name AA, X modification_date AB") + + def test_rest_path_by_attr(self): ctrl, rset = self.process('CWUser/login/admin') self.assertEqual(ctrl, 'view') self.assertEqual(len(rset), 1) self.assertEqual(rset.description[0][0], 'CWUser') self.assertEqual(rset.printable_rql(), 'Any X,AA,AB,AC,AD WHERE X login "admin", X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD') + + def test_rest_path_unique_attr(self): ctrl, rset = self.process('cwuser/admin') self.assertEqual(ctrl, 'view') self.assertEqual(len(rset), 1) self.assertEqual(rset.description[0][0], 'CWUser') self.assertEqual(rset.printable_rql(), 'Any X,AA,AB,AC,AD WHERE X login "admin", X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD') - ctrl, rset = self.process('cwuser/eid/%s'%rset[0][0]) + + def test_rest_path_eid(self): + ctrl, rset = self.process('cwuser/eid/%s' % self.user().eid) self.assertEqual(ctrl, 'view') self.assertEqual(len(rset), 1) self.assertEqual(rset.description[0][0], 'CWUser') self.assertEqual(rset.printable_rql(), 'Any X,AA,AB,AC,AD WHERE X eid %s, X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD' % rset[0][0]) - # test non-ascii paths + + def test_rest_path_non_ascii_paths(self): ctrl, rset = self.process('CWUser/login/%C3%BFsa%C3%BFe') self.assertEqual(ctrl, 'view') self.assertEqual(len(rset), 1) self.assertEqual(rset.description[0][0], 'CWUser') self.assertEqual(rset.printable_rql(), u'Any X,AA,AB,AC,AD WHERE X login "\xffsa\xffe", X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD') - # test quoted paths + + def test_rest_path_quoted_paths(self): ctrl, rset = self.process('BlogEntry/title/hell%27o') self.assertEqual(ctrl, 'view') self.assertEqual(len(rset), 1) self.assertEqual(rset.description[0][0], 'BlogEntry') self.assertEqual(rset.printable_rql(), u'Any X,AA,AB,AC WHERE X title "hell\'o", X is BlogEntry, X creation_date AA, X title AB, X modification_date AC') - # errors + + def test_rest_path_errors(self): self.assertRaises(NotFound, self.process, 'CWUser/eid/30000') self.assertRaises(NotFound, self.process, 'Workcases') self.assertRaises(NotFound, self.process, 'CWUser/inexistant_attribute/joe') diff -r 6665fa16aa45 -r cd2ea273007a web/test/unittest_urlrewrite.py --- a/web/test/unittest_urlrewrite.py Fri Feb 18 09:33:51 2011 +0100 +++ b/web/test/unittest_urlrewrite.py Fri Feb 18 10:18:28 2011 +0100 @@ -47,12 +47,14 @@ ('/schema', dict(vid='schema')), ('/myprefs', dict(vid='propertiesform')), ('/siteconfig', dict(vid='systempropertiesform')), - ('/siteinfo', dict(vid='info')), + ('/siteinfo', dict(vid='siteinfo')), ('/manage', dict(vid='manage')), ('/notfound', dict(vid='404')), ('/error', dict(vid='error')), ('/sparql', dict(vid='sparql')), ('/processinfo', dict(vid='processinfo')), + ('/cwuser$', {'vid': 'cw.user-management'}), + ('/cwsource$', {'vid': 'cw.source-management'}), ('/schema/([^/]+?)/?$', {'rql': r'Any X WHERE X is CWEType, X name "\1"', 'vid': 'primary'}), ('/add/([^/]+?)/?$' , dict(vid='creation', etype=r'\1')), ('/doc/images/(.+?)/?$', dict(fid='\\1', vid='wdocimages')), diff -r 6665fa16aa45 -r cd2ea273007a web/test/unittest_viewselector.py --- a/web/test/unittest_viewselector.py Fri Feb 18 09:33:51 2011 +0100 +++ b/web/test/unittest_viewselector.py Fri Feb 18 10:18:28 2011 +0100 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -27,25 +27,32 @@ traced_selection) from cubicweb.web import NoSelectableObject from cubicweb.web.action import Action -from cubicweb.web.views import (primary, baseviews, tableview, editforms, - calendar, management, embedding, actions, - startup, cwuser, schema, xbel, vcard, owl, - treeview, idownloadable, wdoc, debug, - cwproperties, workflow, xmlrss, csvexport) +from cubicweb.web.views import ( + primary, baseviews, tableview, editforms, calendar, management, embedding, + actions, startup, cwuser, schema, xbel, vcard, owl, treeview, idownloadable, + wdoc, debug, cwuser, cwproperties, cwsources, workflow, xmlrss, rdf, + csvexport) from cubes.folder import views as folderviews USERACTIONS = [actions.UserPreferencesAction, actions.UserInfoAction, actions.LogoutAction] -SITEACTIONS = [actions.SiteConfigurationAction, - actions.ManageAction, - schema.ViewSchemaAction, - debug.SiteInfoAction] +SITEACTIONS = [actions.ManageAction] FOOTERACTIONS = [wdoc.HelpAction, wdoc.ChangeLogAction, wdoc.AboutAction, actions.PoweredByAction] +MANAGEACTIONS = [actions.SiteConfigurationAction, + schema.ViewSchemaAction, + cwuser.ManageUsersAction, + cwsources.ManageSourcesAction, + debug.SiteInfoAction] + +if hasattr(rdf, 'RDFView') is not None: # not available if rdf lib not installed + RDFVIEWS = [('rdf', rdf.RDFView)] + +assert RDFVIEWS class ViewSelectorTC(CubicWebTC): @@ -83,6 +90,8 @@ req = self.request() self.assertListEqual(self.pviews(req, None), [('changelog', wdoc.ChangeLogView), + ('cw.source-management', cwsources.CWSourceManagementView), + ('cw.user-management', cwuser.CWUserManagementView), ('gc', debug.GCView), ('index', startup.IndexView), ('info', debug.ProcessInformationView), @@ -91,6 +100,7 @@ ('propertiesform', cwproperties.CWPropertiesForm), ('registry', debug.RegistryView), ('schema', schema.SchemaView), + ('siteinfo', debug.SiteInfoView), ('systempropertiesform', cwproperties.SystemCWPropertiesForm), ('tree', folderviews.FolderTreeView), ]) @@ -112,7 +122,7 @@ ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('owlabox', owl.OWLABOXView), - ('primary', cwuser.CWGroupPrimaryView), + ('primary', cwuser.CWGroupPrimaryView)] + RDFVIEWS + [ ('rsetxml', xmlrss.XMLRsetView), ('rss', xmlrss.RSSView), ('sameetypelist', baseviews.SameETypeListView), @@ -136,7 +146,7 @@ ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('owlabox', owl.OWLABOXView), - ('primary', cwuser.CWGroupPrimaryView), + ('primary', cwuser.CWGroupPrimaryView)] + RDFVIEWS + [ ('rsetxml', xmlrss.XMLRsetView), ('rss', xmlrss.RSSView), ('sameetypelist', baseviews.SameETypeListView), @@ -191,7 +201,7 @@ ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('owlabox', owl.OWLABOXView), - ('primary', primary.PrimaryView), + ('primary', primary.PrimaryView),] + RDFVIEWS + [ ('rsetxml', xmlrss.XMLRsetView), ('rss', xmlrss.RSSView), ('secondary', baseviews.SecondaryView), @@ -218,6 +228,7 @@ rset = req.execute('CWUser X') self.assertListEqual(self.pviews(req, rset), [('csvexport', csvexport.CSVRsetView), + ('cw.user-table', cwuser.CWUserTable), ('ecsvexport', csvexport.CSVEntityView), ('editable-table', tableview.EditableTableView), ('filetree', treeview.FileTreeView), @@ -225,7 +236,7 @@ ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('owlabox', owl.OWLABOXView), - ('primary', primary.PrimaryView), + ('primary', primary.PrimaryView)] + RDFVIEWS + [ ('rsetxml', xmlrss.XMLRsetView), ('rss', xmlrss.RSSView), ('sameetypelist', baseviews.SameETypeListView), @@ -244,6 +255,7 @@ self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, }) @@ -253,6 +265,7 @@ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, }) @@ -262,6 +275,7 @@ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, 'mainactions': [actions.MultipleEditAction], 'moreactions': [actions.DeleteAction, @@ -274,6 +288,7 @@ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, 'moreactions': [actions.DeleteAction], }) @@ -284,6 +299,7 @@ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, }) @@ -293,6 +309,7 @@ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, + 'manage': MANAGEACTIONS, 'footer': FOOTERACTIONS, 'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], @@ -508,6 +525,7 @@ {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, 'footer': FOOTERACTIONS, + 'manage': MANAGEACTIONS, 'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], 'moreactions': [actions.ManagePermissionsAction, actions.AddRelatedActions, @@ -522,6 +540,7 @@ {'useractions': USERACTIONS, 'siteactions': SITEACTIONS, 'footer': FOOTERACTIONS, + 'manage': MANAGEACTIONS, 'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], 'moreactions': [actions.ManagePermissionsAction, actions.AddRelatedActions,