--- a/web/test/unittest_magicsearch.py Sun Aug 02 11:54:02 2009 +0200
+++ b/web/test/unittest_magicsearch.py Sun Aug 02 11:54:48 2009 +0200
@@ -169,10 +169,11 @@
(u'Utilisateur P', (u"CWUser P",)),
(u'Utilisateur cubicweb', (u'CWUser C WHERE C has_text %(text)s', {'text': u'cubicweb'})),
(u'CWUser prénom cubicweb', (u'CWUser C WHERE C firstname %(text)s', {'text': 'cubicweb'},)),
- (u'Any X WHERE X is Something', (u"Any X WHERE X is Something",)),
]
for query, expected in queries:
self.assertEquals(self.proc.preprocess_query(query, self.req), expected)
+ self.assertRaises(BadRQLQuery,
+ self.proc.preprocess_query, 'Any X WHERE X is Something', self.req)
--- a/web/test/unittest_viewselector.py Sun Aug 02 11:54:02 2009 +0200
+++ b/web/test/unittest_viewselector.py Sun Aug 02 11:54:48 2009 +0200
@@ -74,7 +74,7 @@
('manage', startup.ManageView),
('owl', owl.OWLView),
('propertiesform', cwproperties.CWPropertiesForm),
- ('schema', startup.SchemaView),
+ ('schema', schema.SchemaView),
('systempropertiesform', cwproperties.SystemCWPropertiesForm)])
def test_possible_views_noresult(self):
@@ -85,7 +85,8 @@
def test_possible_views_one_egroup(self):
rset, req = self.env.get_rset_and_req('CWGroup X WHERE X name "managers"')
self.assertListEqual(self.pviews(req, rset),
- [('csvexport', csvexport.CSVRsetView),
+ [('adaptedlist', baseviews.AdaptedListView),
+ ('csvexport', csvexport.CSVRsetView),
('ecsvexport', csvexport.CSVEntityView),
('editable-table', tableview.EditableTableView),
('filetree', treeview.FileTreeView),
@@ -107,7 +108,8 @@
def test_possible_views_multiple_egroups(self):
rset, req = self.env.get_rset_and_req('CWGroup X')
self.assertListEqual(self.pviews(req, rset),
- [('csvexport', csvexport.CSVRsetView),
+ [('adaptedlist', baseviews.AdaptedListView),
+ ('csvexport', csvexport.CSVRsetView),
('ecsvexport', csvexport.CSVEntityView),
('editable-table', tableview.EditableTableView),
('filetree', treeview.FileTreeView),
@@ -130,26 +132,26 @@
assert self.vreg['views']['propertiesform']
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
- self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=None))
- self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=rset1))
- self.failUnless(self.vreg.select_object('views', 'propertiesform', req2, rset=rset2))
+ self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=None))
+ self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=rset1))
+ self.failUnless(self.vreg.select('views', 'propertiesform', req2, rset=rset2))
def test_propertiesform_anon(self):
self.login('anon')
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
- self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=None)
- self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset1)
- self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset2)
+ self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=None)
+ self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset1)
+ self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset2)
def test_propertiesform_jdoe(self):
self.create_user('jdoe')
self.login('jdoe')
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "jdoe"')
- self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=None))
- self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset1)
- self.failUnless(self.vreg.select_object('views', 'propertiesform', req2, rset=rset2))
+ self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=None))
+ self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset1)
+ self.failUnless(self.vreg.select('views', 'propertiesform', req2, rset=rset2))
def test_possible_views_multiple_different_types(self):
rset, req = self.env.get_rset_and_req('Any X')
@@ -185,7 +187,8 @@
def test_possible_views_multiple_eusers(self):
rset, req = self.env.get_rset_and_req('CWUser X')
self.assertListEqual(self.pviews(req, rset),
- [('csvexport', csvexport.CSVRsetView),
+ [('adaptedlist', baseviews.AdaptedListView),
+ ('csvexport', csvexport.CSVRsetView),
('ecsvexport', csvexport.CSVEntityView),
('editable-table', tableview.EditableTableView),
('filetree', treeview.FileTreeView),
--- a/web/test/unittest_web.py Sun Aug 02 11:54:02 2009 +0200
+++ b/web/test/unittest_web.py Sun Aug 02 11:54:48 2009 +0200
@@ -6,19 +6,17 @@
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
from logilab.common.testlib import TestCase, unittest_main
-from cubicweb.web import ajax_replace_url as arurl
+from cubicweb.devtools.fake import FakeRequest
class AjaxReplaceUrlTC(TestCase):
def test_ajax_replace_url(self):
+ req = FakeRequest()
+ arurl = req.build_ajax_replace_url
# NOTE: for the simplest use cases, we could use doctest
- self.assertEquals(arurl('foo', 'Person P'),
- "javascript: replacePageChunk('foo', 'Person%20P');")
- self.assertEquals(arurl('foo', 'Person P', 'oneline'),
- "javascript: replacePageChunk('foo', 'Person%20P', 'oneline');")
+ self.assertEquals(arurl('foo', 'Person P', 'list'),
+ "javascript: loadxhtml('foo', 'http://testing.fr/cubicweb/view?rql=Person%20P&__notemplate=1&vid=list', 'replace')")
self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12),
- 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});')
- self.assertEquals(arurl('foo', 'Person P', name='bar', age=12),
- 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});')
+ '''javascript: loadxhtml('foo', 'http://testing.fr/cubicweb/view?age=12&rql=Person%20P&__notemplate=1&vid=oneline&name=bar', 'replace')''')
if __name__ == '__main__':