186 self.assertEqual(2, len(got)) |
187 self.assertEqual(2, len(got)) |
187 # this is a custom type attribute with an extra parameter |
188 # this is a custom type attribute with an extra parameter |
188 self.assertIn('extra_props', got[1][1]) |
189 self.assertIn('extra_props', got[1][1]) |
189 # this extr |
190 # this extr |
190 extra_props = got[1][1]['extra_props'] |
191 extra_props = got[1][1]['extra_props'] |
191 from cubicweb import Binary |
|
192 self.assertIsInstance(extra_props, Binary) |
192 self.assertIsInstance(extra_props, Binary) |
193 got[1][1]['extra_props'] = got[1][1]['extra_props'].getvalue() |
193 got[1][1]['extra_props'] = got[1][1]['extra_props'].getvalue() |
194 self.assertListEqual(expected, got) |
194 self.assertListEqual(expected, got) |
195 |
195 |
196 def test_rdef2rql(self): |
196 def test_rdef2rql(self): |
197 self.assertListEqual([ |
197 self.assertListEqual([ |
198 ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s', |
198 ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s', |
199 {'se': None, 'rt': None, 'oe': None, |
199 {'se': None, 'rt': None, 'oe': None, |
200 'description': u'', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 3, 'defaultval': u'text/plain', 'indexed': False, 'cardinality': u'?1'}), |
200 'description': u'', 'internationalizable': True, 'fulltextindexed': False, |
|
201 'ordernum': 3, 'defaultval': Binary('text/plain'), 'indexed': False, 'cardinality': u'?1'}), |
201 ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s', |
202 ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s', |
202 {'x': None, 'value': u'None', 'ct': 'FormatConstraint_eid'}), |
203 {'x': None, 'value': u'None', 'ct': 'FormatConstraint_eid'}), |
203 ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s', |
204 ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s', |
204 {'x': None, 'value': u'max=50', 'ct': 'SizeConstraint_eid'})], |
205 {'x': None, 'value': u'max=50', 'ct': 'SizeConstraint_eid'})], |
205 list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap))) |
206 list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap))) |