78 with self.admin_access.web_request() as req: |
76 with self.admin_access.web_request() as req: |
79 b = req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
77 b = req.create_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
80 t = req.create_entity('Tag', name=u'x') |
78 t = req.create_entity('Tag', name=u'x') |
81 form1 = self.vreg['forms'].select('edition', req, entity=t) |
79 form1 = self.vreg['forms'].select('edition', req, entity=t) |
82 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
80 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
83 self.assertIn(text_type(b.eid), choices) |
81 self.assertIn(str(b.eid), choices) |
84 form2 = self.vreg['forms'].select('edition', req, entity=b) |
82 form2 = self.vreg['forms'].select('edition', req, entity=b) |
85 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
83 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
86 self.assertIn(text_type(t.eid), choices) |
84 self.assertIn(str(t.eid), choices) |
87 |
85 |
88 b.cw_clear_all_caches() |
86 b.cw_clear_all_caches() |
89 t.cw_clear_all_caches() |
87 t.cw_clear_all_caches() |
90 req.cnx.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
88 req.cnx.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
91 |
89 |
92 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
90 choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] |
93 self.assertIn(text_type(b.eid), choices) |
91 self.assertIn(str(b.eid), choices) |
94 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
92 choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] |
95 self.assertIn(text_type(t.eid), choices) |
93 self.assertIn(str(t.eid), choices) |
96 |
94 |
97 def test_form_field_choices_new_entity(self): |
95 def test_form_field_choices_new_entity(self): |
98 with self.admin_access.web_request() as req: |
96 with self.admin_access.web_request() as req: |
99 e = self.vreg['etypes'].etype_class('CWUser')(req) |
97 e = self.vreg['etypes'].etype_class('CWUser')(req) |
100 form = self.vreg['forms'].select('edition', req, entity=e) |
98 form = self.vreg['forms'].select('edition', req, entity=e) |