62 def test_form_field_vocabulary_unrelated(self): |
62 def test_form_field_vocabulary_unrelated(self): |
63 b = self.req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
63 b = self.req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
64 t = self.req.create_entity('Tag', name=u'x') |
64 t = self.req.create_entity('Tag', name=u'x') |
65 form1 = self.vreg['forms'].select('edition', self.req, entity=t) |
65 form1 = self.vreg['forms'].select('edition', self.req, entity=t) |
66 unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
66 unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
67 self.failUnless(unicode(b.eid) in unrelated, unrelated) |
67 self.assertTrue(unicode(b.eid) in unrelated, unrelated) |
68 form2 = self.vreg['forms'].select('edition', self.req, entity=b) |
68 form2 = self.vreg['forms'].select('edition', self.req, entity=b) |
69 unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
69 unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
70 self.failUnless(unicode(t.eid) in unrelated, unrelated) |
70 self.assertTrue(unicode(t.eid) in unrelated, unrelated) |
71 self.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
71 self.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
72 unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
72 unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
73 self.failIf(unicode(b.eid) in unrelated, unrelated) |
73 self.assertFalse(unicode(b.eid) in unrelated, unrelated) |
74 unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
74 unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
75 self.failIf(unicode(t.eid) in unrelated, unrelated) |
75 self.assertFalse(unicode(t.eid) in unrelated, unrelated) |
76 |
76 |
77 |
77 |
78 def test_form_field_vocabulary_new_entity(self): |
78 def test_form_field_vocabulary_new_entity(self): |
79 e = self.vreg['etypes'].etype_class('CWUser')(self.request()) |
79 e = self.vreg['etypes'].etype_class('CWUser')(self.request()) |
80 form = self.vreg['forms'].select('edition', self.req, entity=e) |
80 form = self.vreg['forms'].select('edition', self.req, entity=e) |
108 self.assertEqual(optionnode.get('value'), str(geid)) |
108 self.assertEqual(optionnode.get('value'), str(geid)) |
109 self.assertEqual(ok, False) |
109 self.assertEqual(ok, False) |
110 ok = True |
110 ok = True |
111 self.assertEqual(ok, True, 'expected option not found') |
111 self.assertEqual(ok, True, 'expected option not found') |
112 inputs = pageinfo.find_tag('input', False) |
112 inputs = pageinfo.find_tag('input', False) |
113 self.failIf(list(pageinfo.matching_nodes('input', name='__linkto'))) |
113 self.assertFalse(list(pageinfo.matching_nodes('input', name='__linkto'))) |
114 |
114 |
115 def test_reledit_composite_field(self): |
115 def test_reledit_composite_field(self): |
116 rset = self.execute('INSERT BlogEntry X: X title "cubicweb.org", X content "hop"') |
116 rset = self.execute('INSERT BlogEntry X: X title "cubicweb.org", X content "hop"') |
117 form = self.vreg['views'].select('reledit', self.request(), |
117 form = self.vreg['views'].select('reledit', self.request(), |
118 rset=rset, row=0, rtype='content') |
118 rset=rset, row=0, rtype='content') |
119 data = form.render(row=0, rtype='content', formid='base', action='edit_rtype') |
119 data = form.render(row=0, rtype='content', formid='base', action='edit_rtype') |
120 self.failUnless('content_format' in data) |
120 self.assertTrue('content_format' in data) |
121 |
121 |
122 # form view tests ######################################################### |
122 # form view tests ######################################################### |
123 |
123 |
124 def test_massmailing_formview(self): |
124 def test_massmailing_formview(self): |
125 self.execute('INSERT EmailAddress X: X address L + "@cubicweb.org", ' |
125 self.execute('INSERT EmailAddress X: X address L + "@cubicweb.org", ' |