Пример #1
0
def test_fixed_field_order():
    schema = {
        "size": 4,
        "name": "test_fixed_field_order",
        "type": "fixed",
    }

    assert (to_parsing_canonical_form(schema) ==
            '{"name":"test_fixed_field_order","type":"fixed","size":4}')
Пример #2
0
def test_record_field_order():
    schema = {
        "fields": [],
        "name": "test_record_field_order",
        "type": "record",
    }

    assert (to_parsing_canonical_form(schema) ==
            '{"name":"test_record_field_order","type":"record","fields":[]}')
Пример #3
0
def test_enum_field_order():
    schema = {
        "symbols": ["A", "B"],
        "name": "test_enum_field_order",
        "type": "enum",
    }

    assert (
        to_parsing_canonical_form(schema) ==
        '{"name":"test_enum_field_order","type":"enum","symbols":["A","B"]}')
Пример #4
0
def test_remove_aliases():
    schema = {
        "name": "test_remove_aliases",
        "type": "record",
        "fields": [],
        "aliases": "alias",
    }

    assert (to_parsing_canonical_form(schema) ==
            '{"name":"test_remove_aliases","type":"record","fields":[]}')
Пример #5
0
def test_remove_doc():
    schema = {
        "name": "test_remove_doc",
        "type": "record",
        "fields": [],
        "doc": "doc"
    }

    assert (to_parsing_canonical_form(schema) ==
            '{"name":"test_remove_doc","type":"record","fields":[]}')
Пример #6
0
def test_fullname_conversion_no_namespace():
    schema = {
        "name": "test_fullname_conversion_no_namespace",
        "type": "record",
        "fields": [],
    }

    assert (
        to_parsing_canonical_form(schema) ==
        '{"name":"test_fullname_conversion_no_namespace","type":"record","fields":[]}'
    )
Пример #7
0
def test_random_cases(original_schema, algorithm, expected_fingerprint):
    # All of these random test cases came from the test cases here:
    # https://github.com/apache/avro/blob/0552c674637dd15b8751ed5181387cdbd81480d5/lang/py3/avro/tests/test_normalization.py
    canonical_form = to_parsing_canonical_form(original_schema)
    assert fingerprint(canonical_form, algorithm) == expected_fingerprint
Пример #8
0
def test_random_cases(original_schema, canonical_form):
    # All of these random test cases came from the test cases here:
    # https://github.com/apache/avro/blob/0552c674637dd15b8751ed5181387cdbd81480d5/lang/py3/avro/tests/test_normalization.py
    assert to_parsing_canonical_form(original_schema) == canonical_form
Пример #9
0
def test_primitive_conversion(original_schema, canonical_form):
    assert to_parsing_canonical_form(original_schema) == canonical_form
Пример #10
0
def test_map_field_order():
    schema = {"values": "int", "type": "map"}

    assert to_parsing_canonical_form(schema) == '{"type":"map","values":"int"}'
Пример #11
0
def test_array_field_order():
    schema = {"items": "int", "type": "array"}

    assert to_parsing_canonical_form(
        schema) == '{"type":"array","items":"int"}'