예제 #1
0
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']
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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'])
예제 #5
0
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