Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
libretto committed Sep 26, 2024
1 parent c156fe9 commit 9cac0ba
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions tests/unit/test_avro_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,33 @@

class TestAvroMerge:
@pytest.fixture
def setup_avro_merge(self):
def avro_merge(self):
schema_str = '{"type": "record", "name": "Test", "fields": [{"name": "field1", "type": "string"}]}'
dependencies = {"dependency1": MagicMock(schema=MagicMock(schema_str='{"type": "string"}', dependencies=None))}
return AvroMerge(schema_str, dependencies)

def test_init(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_init(self, avro_merge):
assert avro_merge.schema_str == json_encode(json_decode(avro_merge.schema_str), compact=True, sort_keys=True)
assert avro_merge.dependencies == avro_merge.dependencies
assert avro_merge.unique_id == 0

def test_union_safe_schema_str_no_union(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_union_safe_schema_str_no_union(self, avro_merge):

result = avro_merge.union_safe_schema_str('{"type": "string"}')
expected = (
'{"name": "___RESERVED_KARAPACE_WRAPPER_NAME_0___","type": "record", "fields": [{"name": "name", '
'"type": [{"type": "string"}]}]}'
)
assert result == expected

def test_union_safe_schema_str_with_union(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_union_safe_schema_str_with_union(self, avro_merge):
result = avro_merge.union_safe_schema_str('["null", "string"]')
expected = (
'{"name": "___RESERVED_KARAPACE_WRAPPER_NAME_0___","type": "record", "fields": [{"name": "name", '
'"type": ["null", "string"]}]}'
)
assert result == expected

def test_builder_no_dependencies(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_builder_no_dependencies(self, avro_merge):
avro_merge.dependencies = None
result = avro_merge.builder(avro_merge.schema_str)
expected = (
Expand All @@ -54,8 +50,7 @@ def test_builder_no_dependencies(self, setup_avro_merge):
)
assert result == expected

def test_builder_with_dependencies(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_builder_with_dependencies(self, avro_merge):
result = avro_merge.builder(avro_merge.schema_str, avro_merge.dependencies)
expected = (
'{"name": "___RESERVED_KARAPACE_WRAPPER_NAME_1___","type": "record", "fields": [{"name": "name", "type": [{'
Expand All @@ -66,8 +61,7 @@ def test_builder_with_dependencies(self, setup_avro_merge):
)
assert result == expected

def test_wrap(self, setup_avro_merge):
avro_merge = setup_avro_merge
def test_wrap(self, avro_merge):
result = avro_merge.wrap()
expected = (
"[\n"
Expand Down

0 comments on commit 9cac0ba

Please sign in to comment.