Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Sep 24, 2024
1 parent b61472d commit 4ec44de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fixlib/fixlib/core/model_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def literal_name(en: Enum) -> str:
# Use this model exporter, if a dynamic object is exported
# with given name and properties.
def dynamic_object_to_fixcore_model(
name: str, properties: Dict[str, type], aggregate_root: bool = True, traverse_dependant: bool = True
name: str, properties: Dict[str, type], aggregate_root: bool = True, traverse_dependant: bool = True, **kwargs
) -> List[Json]:
dependant = dataclasses_to_fixcore_model(set(properties.values())) if traverse_dependant else []
dependant = dataclasses_to_fixcore_model(set(properties.values()), **kwargs) if traverse_dependant else []
# append definition for top level object
dependant.append(
{
Expand Down
9 changes: 7 additions & 2 deletions fixlib/test/core/model_export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_enum_to_model() -> None:


def test_dataclasses_to_fixcore_model() -> None:
result = dataclasses_to_fixcore_model({DataClassExample})
result = dataclasses_to_fixcore_model({DataClassExample}, with_kind_description=True, with_prop_description=True)
assert len(result) == 5
for r in result:
props = {p["name"]: p for p in r.get("properties", [])}
Expand Down Expand Up @@ -187,7 +187,12 @@ class GcpTestConfigConfig:
def test_config_export():
# Let's assume a dynamic top level object of name Config
# The properties are defined by name and related type.
result = dynamic_object_to_fixcore_model("config", {"aws": AwsTestConfig, "gcp": GcpTestConfigConfig})
result = dynamic_object_to_fixcore_model(
"config",
{"aws": AwsTestConfig, "gcp": GcpTestConfigConfig},
with_kind_description=True,
with_prop_description=True,
)
result_dict = {a["fqn"]: a for a in result}
assert len(result_dict["gcp_config"]["properties"]) == 1
assert len(result_dict["aws_config"]["properties"]) == 2
Expand Down

0 comments on commit 4ec44de

Please sign in to comment.