--- 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')
--- 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,