def test_fixed_schema(): names = core.AvroModelContainer() schema = SchemaFromJSONData(TEST_FIXED_SCHEMA) data_cls = models.create_data_model(schema, WrapperClass, names) assert data_cls.get_size() == TEST_FIXED_SCHEMA['size']
def test_map_schema(): names = core.AvroModelContainer() schema = SchemaFromJSONData(TEST_MAP_SCHEMA) data_cls = models.create_data_model(schema, WrapperClass, names) assert data_cls.get_contained_class() == int
def test_record_schema_model(): schema = SchemaFromJSONData(TEST_RECORD_SCHEMA) record_cls = models.create_data_model(schema, WrapperClass, core.AvroModelContainer()) assert record_cls.get_fields() == schema.fields
def test_enum_schema_model(): schema = SchemaFromJSONData(TEST_ENUM_SCHEMA) data_cls = models.create_data_model(schema, WrapperClass, core.AvroModelContainer()) assert set(data_cls.get_symbols()) == set(TEST_ENUM_SCHEMA['symbols'])
def test_create_data_model_successful(schema_json, expected_type): schema = SchemaFromJSONData(schema_json) data_cls = models.create_data_model(schema, WrapperClass, core.AvroModelContainer()) assert issubclass(data_cls, expected_type) assert data_cls.get_schema() == schema