# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1239192694 -7200 # Node ID 62d2b890a98056a67d135f627b795985285ffdb3 # Parent ca02a2b5e9be7f3e23b35396bc060e77f3f022fa move tests where they belong diff -r ca02a2b5e9be -r 62d2b890a980 web/test/unittest_form.py --- a/web/test/unittest_form.py Wed Apr 08 13:20:05 2009 +0200 +++ b/web/test/unittest_form.py Wed Apr 08 14:11:34 2009 +0200 @@ -19,43 +19,12 @@ # form view tests ######################################################### - def test_delete_conf_formview(self): - rset = self.execute('EGroup X') - self.view('deleteconf', rset, template=None).source - def test_massmailing_formview(self): self.execute('INSERT EmailAddress X: X address L + "@cubicweb.org", ' 'U use_email X WHERE U is EUser, U login L') rset = self.execute('EUser X') self.view('massmailing', rset, template=None) - def test_automatic_edition_formview(self): - rset = self.execute('EUser X') - self.view('edition', rset, row=0, template=None).source - - def test_automatic_edition_formview(self): - rset = self.execute('EUser X') - self.view('copy', rset, row=0, template=None).source - - def test_automatic_creation_formview(self): - self.view('creation', None, etype='EUser', template=None).source - - def test_automatic_muledit_formview(self): - rset = self.execute('EUser X') - self.view('muledit', rset, template=None).source - - def test_automatic_reledit_formview(self): - rset = self.execute('EUser X') - self.view('reledit', rset, row=0, rtype='login', template=None).source - - def test_automatic_inline_edit_formview(self): - geid = self.execute('EGroup X LIMIT 1')[0][0] - rset = self.execute('EUser X LIMIT 1') - self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source - - def test_automatic_inline_creation_formview(self): - geid = self.execute('EGroup X LIMIT 1')[0][0] - self.view('inline-creation', None, etype='EUser', rtype='in_group', peid=geid, template=None).source # form tests ############################################################## @@ -72,13 +41,6 @@ entity=self.entity) form.form_render(state=123, trcomment=u'') - def test_edition_form(self): - rset = self.execute('EUser X LIMIT 1') - form = self.vreg.select_object('forms', 'edition', rset.req, rset, row=0, col=0) - # should be also selectable by specifying entity - self.vreg.select_object('forms', 'edition', self.request(), entity=rset.get_entity(0, 0)) - self.failIf(any(f for f in form.fields if f is None)) - # fields tests ############################################################ def _render_entity_field(self, name, form): @@ -99,10 +61,10 @@ def test_richtextfield_1(self): self.req.use_fckeditor = lambda: False self._test_richtextfield('''''') @@ -163,7 +125,7 @@ self.assertTextEquals(self._render_entity_field('upassword', form), '''
- +   confirm password''' % {'eid': self.entity.eid}) diff -r ca02a2b5e9be -r 62d2b890a980 web/test/unittest_views_editforms.py --- a/web/test/unittest_views_editforms.py Wed Apr 08 13:20:05 2009 +0200 +++ b/web/test/unittest_views_editforms.py Wed Apr 08 14:11:34 2009 +0200 @@ -1,5 +1,6 @@ from logilab.common.testlib import unittest_main from cubicweb.devtools.apptest import EnvBasedTC +from cubicweb.devtools.testlib import WebTest from cubicweb.web.views.editforms import AutomaticEntityForm as AEF def rbc(entity, category): @@ -40,19 +41,22 @@ ]) # owned_by is defined both as subject and object relations on EUser self.assertListEquals(rbc(e, 'generated'), - [('is', 'subject'), + [('has_text', 'subject'), + ('identity', 'subject'), + ('is', 'subject'), ('is_instance_of', 'subject'), ('tags', 'object'), ('for_user', 'object'), ('created_by', 'object'), ('wf_info_for', 'object'), ('owned_by', 'object'), + ('identity', 'object'), ]) def test_inlined_view(self): self.failUnless(AEF.rinlined.etype_rtag('EUser', 'use_email', 'subject')) self.failIf(AEF.rinlined.etype_rtag('EUser', 'primary_email', 'subject')) - + def test_personne_relations_by_category(self): e = self.etype_instance('Personne') self.assertListEquals(rbc(e, 'primary'), @@ -84,8 +88,56 @@ ('connait', 'object') ]) self.assertListEquals(rbc(e, 'generated'), - [('is', 'subject'), + [('has_text', 'subject'), + ('identity', 'subject'), + ('is', 'subject'), ('is_instance_of', 'subject'), + ('identity', 'object'), ]) + + def test_edition_form(self): + rset = self.execute('EUser X LIMIT 1') + form = self.vreg.select_object('forms', 'edition', rset.req, rset, + row=0, col=0) + # should be also selectable by specifying entity + self.vreg.select_object('forms', 'edition', self.request(), None, + entity=rset.get_entity(0, 0)) + self.failIf(any(f for f in form.fields if f is None)) + + +class FormViewsTC(WebTest): + def test_delete_conf_formview(self): + rset = self.execute('EGroup X') + self.view('deleteconf', rset, template=None).source + + def test_automatic_edition_formview(self): + rset = self.execute('EUser X') + self.view('edition', rset, row=0, template=None).source + + def test_automatic_edition_formview(self): + rset = self.execute('EUser X') + self.view('copy', rset, row=0, template=None).source + + def test_automatic_creation_formview(self): + self.view('creation', None, etype='EUser', template=None).source + + def test_automatic_muledit_formview(self): + rset = self.execute('EUser X') + self.view('muledit', rset, template=None).source + + def test_automatic_reledit_formview(self): + rset = self.execute('EUser X') + self.view('reledit', rset, row=0, rtype='login', template=None).source + + def test_automatic_inline_edit_formview(self): + geid = self.execute('EGroup X LIMIT 1')[0][0] + rset = self.execute('EUser X LIMIT 1') + self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source + + def test_automatic_inline_creation_formview(self): + geid = self.execute('EGroup X LIMIT 1')[0][0] + self.view('inline-creation', None, etype='EUser', rtype='in_group', peid=geid, template=None).source + + if __name__ == '__main__': unittest_main()