Skip to content

Commit

Permalink
Merge pull request #25 from PrefectHQ/exception-for-deployment
Browse files Browse the repository at this point in the history
Add known incompatibilities to compat-tests
  • Loading branch information
jakekaplan authored Jun 3, 2024
2 parents c5672ab + 4cf6dce commit 3c5ec01
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions test_oss_cloud_api_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def load_schema(fpath: str, key: str = None):
"DeploymentResponse": ["job_variables"],
}

# Properties for endpoints that are known to be incompatible between OSS and Cloud
# so we want to skip them in the comparison.
# The format is endpoint:method:field:<set of properties to ignore>
# options are: "name", "types", "format", "default", "deprecated"
KNOWN_INCOMPATIBLE_API_REQUEST_PROPS = {
"/api/deployments/": {
"post": {
"enforce_parameter_schema": {"default"},
}
}
}


def generate_oss_paths_by_method():
oss_paths: dict[str, dict[str, dict]] = load_schema("oss_schema.json", key="paths")
Expand Down Expand Up @@ -326,11 +338,22 @@ def extract_types(d):
# while Cloud does not.
oss_types.discard("null")

assert oss_name == cloud_name
assert oss_types <= cloud_types
assert oss_format == cloud_format
assert oss_default == cloud_default
assert oss_deprecated == cloud_deprecated
known_incompatible_props = KNOWN_INCOMPATIBLE_API_REQUEST_PROPS.get(endpoint, {}).get(method, {}).get(oss_name, set())

if "name" not in known_incompatible_props:
assert oss_name == cloud_name

if "types" not in known_incompatible_props:
assert oss_types <= cloud_types

if "format" not in known_incompatible_props:
assert oss_format == cloud_format

if "default" not in known_incompatible_props:
assert oss_default == cloud_default

if "deprecated" not in known_incompatible_props:
assert oss_deprecated == cloud_deprecated


@pytest.mark.parametrize(
Expand Down

0 comments on commit 3c5ec01

Please sign in to comment.