63 with self.admin_access.web_request() as req: |
65 with self.admin_access.web_request() as req: |
64 b = req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
66 b = req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
65 t = req.create_entity('Tag', name=u'x') |
67 t = req.create_entity('Tag', name=u'x') |
66 form1 = self.vreg['forms'].select('edition', req, entity=t) |
68 form1 = self.vreg['forms'].select('edition', req, entity=t) |
67 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
69 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
68 self.assertIn(unicode(b.eid), choices) |
70 self.assertIn(text_type(b.eid), choices) |
69 form2 = self.vreg['forms'].select('edition', req, entity=b) |
71 form2 = self.vreg['forms'].select('edition', req, entity=b) |
70 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
72 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
71 self.assertIn(unicode(t.eid), choices) |
73 self.assertIn(text_type(t.eid), choices) |
72 |
74 |
73 b.cw_clear_all_caches() |
75 b.cw_clear_all_caches() |
74 t.cw_clear_all_caches() |
76 t.cw_clear_all_caches() |
75 req.cnx.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
77 req.cnx.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
76 |
78 |
77 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
79 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
78 self.assertIn(unicode(b.eid), choices) |
80 self.assertIn(text_type(b.eid), choices) |
79 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
81 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
80 self.assertIn(unicode(t.eid), choices) |
82 self.assertIn(text_type(t.eid), choices) |
81 |
83 |
82 def test_form_field_choices_new_entity(self): |
84 def test_form_field_choices_new_entity(self): |
83 with self.admin_access.web_request() as req: |
85 with self.admin_access.web_request() as req: |
84 e = self.vreg['etypes'].etype_class('CWUser')(req) |
86 e = self.vreg['etypes'].etype_class('CWUser')(req) |
85 form = self.vreg['forms'].select('edition', req, entity=e) |
87 form = self.vreg['forms'].select('edition', req, entity=e) |