Commit a01ee24d authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

web test update

parent 2d30de60a8ff
......@@ -169,10 +169,11 @@ class QSPreProcessorTC(EnvBasedTC):
(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)
......
......@@ -17,7 +17,7 @@ class AutomaticEntityFormTC(EnvBasedTC):
def test_custom_widget(self):
AEF.rfields_kwargs.tag_subject_of(('CWUser', 'login', '*'),
{'widget':AutoCompletionWidget})
{'widget': AutoCompletionWidget(autocomplete_initfunc='get_logins')})
form = self.vreg.select('forms', 'edition', self.request(),
entity=self.user())
field = form.field_by_name('login')
......
......@@ -74,7 +74,7 @@ class VRegistryTC(ViewSelectorTC):
('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 @@ class VRegistryTC(ViewSelectorTC):
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 @@ class VRegistryTC(ViewSelectorTC):
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 @@ class VRegistryTC(ViewSelectorTC):
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 @@ class VRegistryTC(ViewSelectorTC):
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),
......
......@@ -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__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment