Skip to content

Commit

Permalink
Handling aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguidry committed May 29, 2024
1 parent 8d26ac1 commit 4169182
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions test_oss_cloud_api_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,49 @@ def extract_types(d):
# - new Cloud fields aren't required (this is difficult to check right now as it's method dependent!)
assert cloud_props[0] == oss_props[0]

# Handling of aliases is different between Pydantic v2 and v1, so we'll force
# some name overrides here
KNOWN_ALIASES = {
"/api/flow_runs/history": {
"post": {
"history_interval": "history_interval_seconds",
}
},
"/api/task_runs/history": {
"post": {
"history_interval": "history_interval_seconds",
}
},
"/api/ui/schemas/validate": {
"post": {
"json_schema": "schema",
}
},
}

# ensure every OSS field is present in Cloud
# ensure the property attributes are the same or a subset (like in the case of type)
for field_name, (
for (
oss_name,
oss_types,
oss_format,
oss_default,
oss_deprecated,
) in oss_props[1].items():
assert field_name in cloud_props[1]
) in oss_props[1].values():
print(endpoint, method, oss_name)
if endpoint in KNOWN_ALIASES:
if method in KNOWN_ALIASES[endpoint]:
if oss_name in KNOWN_ALIASES[endpoint][method]:
oss_name = KNOWN_ALIASES[endpoint][method][oss_name]

assert oss_name in cloud_props[1]
(
cloud_name,
cloud_types,
cloud_format,
cloud_default,
cloud_deprecated,
) = cloud_props[1][field_name]
) = cloud_props[1][oss_name]

# In Pydantic v2, if a field is not required, it's format is not included, so
# we need to remove it from the comparison
Expand Down

0 comments on commit 4169182

Please sign in to comment.