class SchemaFieldTestCase(BaseFieldTestCase): field_class = fields.SchemaField EXAMPLE_VALUES = [SimpleSchema(charfield='charmander')] EXAMPLE_PRIMITIVE_VALUES = [{'charfield': 'charmander'}] NULL_VALUE = None def get_field_kwargs(self): return {'schema': SimpleSchema}
def test_to_primitive(self): obj = SimpleSchema(_python_data={'charfield':'charmander'}) prim_data = obj.to_primitive(obj) self.assertEqual(prim_data, {'charfield':'charmander'})
def test_traverse(self): obj = SimpleSchema(charfield='charmander') self.assertEqual(obj.dot_notation('charfield'), 'charmander')
def test_from_portable_primitive(self): obj = SimpleSchema(_primitive_data={'charfield':'charmander'}) assert obj.charfield, 'Failed to initialize python data' py_obj = obj.to_python({'charfield':'charmander'}) py_obj.normalize_portable_primitives() self.assertEqual(obj._primitive_data, py_obj._primitive_data)
def test_to_python(self): obj = SimpleSchema(_primitive_data={'charfield':'charmander'}) py_obj = obj.to_python({'charfield':'charmander'}) self.assertEqual(obj._primitive_data, py_obj._primitive_data)