Skip to content

Commit

Permalink
Document test
Browse files Browse the repository at this point in the history
  • Loading branch information
cutoffthetop committed Dec 15, 2023
1 parent e389038 commit 3063489
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/models/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def sub_only_text(repl: Callable[[str], str], string: str) -> str:


def prepare_field(field: str, obj: list[Any] | dict[str, Any]) -> None:
# prepare each item in a list
# prepare each item in a list (in-place)
if isinstance(obj, list):
for item in obj:
prepare_field(field, item)
Expand All @@ -111,6 +111,8 @@ def prepare_field(field: str, obj: list[Any] | dict[str, Any]) -> None:
obj["format"] = "date-time"

# align reference paths
# (the paths to referenced vocabularies and types differ between the models
# and the specification, so we need to make sure they match before comparing)
if obj.get("pattern") == MEX_ID_PATTERN:
obj.pop("pattern")
obj.pop("type")
Expand All @@ -125,6 +127,7 @@ def prepare_field(field: str, obj: list[Any] | dict[str, Any]) -> None:
obj["$ref"] = f"/schema/fields/{vocabulary}"

# make sure all refs have paths in kebab-case
# (the models use the class names, whereas the spec uses kebab-case URLs)
if "$ref" in obj:
obj["$ref"] = sub_only_text(dromedary_to_kebab, obj["$ref"])

Expand Down

0 comments on commit 3063489

Please sign in to comment.