Skip to content

Commit

Permalink
Touch up tests for new version of pydantic
Browse files Browse the repository at this point in the history
  • Loading branch information
cicdw committed Sep 9, 2024
1 parent 3db5fd8 commit ce77eac
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/integrations/prefect-kubernetes/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def enable_store_api_key_in_secret(monkeypatch):
"cluster_config": {
"title": "Cluster Config",
"description": "The Kubernetes cluster config to use for job creation.",
"allOf": [{"$ref": "#/definitions/KubernetesClusterConfig"}],
"$ref": "#/definitions/KubernetesClusterConfig",
},
},
"definitions": {
Expand Down Expand Up @@ -870,7 +870,7 @@ def enable_store_api_key_in_secret(monkeypatch):
"cluster_config": {
"title": "Cluster Config",
"description": "The Kubernetes cluster config to use for job creation.",
"allOf": [{"$ref": "#/definitions/KubernetesClusterConfig"}],
"$ref": "#/definitions/KubernetesClusterConfig",
},
"memory": {
"title": "Memory",
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/infrastructure/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def generate_work_pool_base_job_template(self):
"description": (
"The infrastructure block to use for job creation."
),
"allOf": [{"$ref": f"#/definitions/{self.__class__.__name__}"}],
"$ref": f"#/definitions/{self.__class__.__name__}",
"default": {
"$ref": {"block_document_id": str(self._block_document_id)}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/collections_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def k8s_default_base_job_template():
"description": (
"The Kubernetes cluster config to use for job creation."
),
"allOf": [{"$ref": "#/definitions/KubernetesClusterConfig"}],
"$ref": "#/definitions/KubernetesClusterConfig",
},
},
"definitions": {
Expand Down
2 changes: 1 addition & 1 deletion tests/infrastructure/provisioners/test_cloud_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"The GCP Credentials used to initiate the Cloud Run Job."
" `service_account_info` is required."
),
"allOf": [{"$ref": "#/definitions/GcpCredentials"}],
"$ref": "#/definitions/GcpCredentials",
},
"image": {
"title": "Image Name",
Expand Down
2 changes: 1 addition & 1 deletion tests/infrastructure/provisioners/test_cloud_run_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"credentials": {
"title": "GCP Credentials",
"description": "The GCP Credentials used to connect to Cloud Run. If not provided credentials will be inferred from the local environment.",
"allOf": [{"$ref": "#/definitions/GcpCredentials"}],
"$ref": "#/definitions/GcpCredentials",
},
"region": {
"title": "Region",
Expand Down
4 changes: 1 addition & 3 deletions tests/infrastructure/provisioners/test_container_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ def default_base_job_template():
"aci_credentials": {
"title": "Aci Credentials",
"description": "The credentials to use to authenticate with Azure.",
"allOf": [
{"$ref": "#/definitions/AzureContainerInstanceCredentials"}
],
"$ref": "#/definitions/AzureContainerInstanceCredentials",
},
"stream_output": {
"title": "Stream Output",
Expand Down
4 changes: 2 additions & 2 deletions tests/infrastructure/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ async def test_generate_work_pool_base_job_template():
"block": {
"title": "Block",
"description": "The infrastructure block to use for job creation.",
"allOf": [{"$ref": "#/definitions/MockInfrastructure"}],
"$ref": "#/definitions/MockInfrastructure",
"default": {
"$ref": {"block_document_id": str(block._block_document_id)}
},
Expand Down Expand Up @@ -358,7 +358,7 @@ async def test_publish_as_work_pool(
"block": {
"title": "Block",
"description": "The infrastructure block to use for job creation.",
"allOf": [{"$ref": "#/definitions/MockInfrastructure"}],
"$ref": "#/definitions/MockInfrastructure",
"default": {
"$ref": {"block_document_id": str(block._block_document_id)}
},
Expand Down
6 changes: 3 additions & 3 deletions tests/server/api/test_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ async def test_create_deployment_parameter_enforcement_allows_partial_parameters
"position": 1,
},
"person": {
"allOf": [{"$ref": "#/definitions/Person"}],
"$ref": "#/definitions/Person",
"position": 0,
},
},
Expand Down Expand Up @@ -1441,7 +1441,7 @@ async def test_update_deployment_parameter_enforcement_allows_partial_parameters
"position": 1,
},
"person": {
"allOf": [{"$ref": "#/definitions/Person"}],
"$ref": "#/definitions/Person",
"position": 0,
},
},
Expand Down Expand Up @@ -2821,7 +2821,7 @@ async def test_create_flow_run_from_deployment_parameter_enforcement_rejects_par
"position": 1,
},
"person": {
"allOf": [{"$ref": "#/definitions/Person"}],
"$ref": "#/definitions/Person",
"position": 0,
},
},
Expand Down
4 changes: 2 additions & 2 deletions tests/server/api/test_infra_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ async def test_base_job_template_default_references_to_blocks(
"required": ["k8s_credentials"],
"properties": {
"k8s_credentials": {
"allOf": [{"$ref": "#/definitions/k8s_credentials"}],
"$ref": "#/definitions/k8s_credentials",
"title": "K8s Credentials",
"default": {
"$ref": {
Expand Down Expand Up @@ -673,7 +673,7 @@ async def test_base_job_template_default_references_to_blocks(
"required": ["k8s_credentials"],
"properties": {
"k8s_credentials": {
"allOf": [{"$ref": "#/definitions/k8s_credentials"}],
"$ref": "#/definitions/k8s_credentials",
"title": "K8s Credentials",
"default": {
"$ref": {
Expand Down
4 changes: 2 additions & 2 deletions tests/server/api/ui/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def test_circular_schema_reference(
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
"required": ["param"],
Expand All @@ -118,7 +118,7 @@ async def test_circular_schema_reference(
},
"required": ["population", "name"],
# City definition references itself here
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
},
Expand Down
54 changes: 27 additions & 27 deletions tests/utilities/schema_tools/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def test_circular_schema_ref():
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
"required": ["param"],
Expand All @@ -74,7 +74,7 @@ async def test_circular_schema_ref():
},
"required": ["population", "name"],
# City definition references itself here
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
}
Expand Down Expand Up @@ -357,7 +357,7 @@ def schema(self) -> dict:
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
"required": ["param"],
Expand Down Expand Up @@ -415,7 +415,7 @@ def schema(self) -> dict:
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
"required": ["param"],
Expand Down Expand Up @@ -634,7 +634,7 @@ def schema(self) -> dict:
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/City"}],
"$ref": "#/definitions/City",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1145,7 +1145,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1176,7 +1176,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1206,7 +1206,7 @@ def test_pydantic_v1_model_required_int_or_none(self):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand All @@ -1233,7 +1233,7 @@ def test_pydantic_v1_model_required_int_or_none(self):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand All @@ -1259,7 +1259,7 @@ def test_pydantic_v1_model_optional_int_or_none_default_none(self):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1287,7 +1287,7 @@ def test_pydantic_v1_model_optional_int_or_none_default_none(self):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1317,7 +1317,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1473,7 +1473,7 @@ def test_pydantic_v2_model_required_int(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1503,7 +1503,7 @@ def test_pydantic_v2_model_optional_int(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1536,7 +1536,7 @@ def test_pydantic_v2_model_optional_int_default_none(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1569,7 +1569,7 @@ def test_pydantic_v2_model_required_int_or_none(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1602,7 +1602,7 @@ def test_pydantic_v2_model_optional_int_or_none_default_none(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1635,7 +1635,7 @@ def test_pydantic_v2_model_optional_int_or_none_default_int(self):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -1789,7 +1789,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1819,7 +1819,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1853,7 +1853,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1886,7 +1886,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1922,7 +1922,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -1954,7 +1954,7 @@ class MyModel(BaseModel):
"param": {
"title": "param",
"position": 0,
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
}
},
"required": ["param"],
Expand Down Expand Up @@ -2061,7 +2061,7 @@ class MyModel(BaseModel):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -2098,7 +2098,7 @@ class MyModel(BaseModel):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down Expand Up @@ -2137,7 +2137,7 @@ class MyModel(BaseModel):
"type": "object",
"properties": {
"param": {
"allOf": [{"$ref": "#/definitions/MyModel"}],
"$ref": "#/definitions/MyModel",
"position": 0,
"title": "param",
}
Expand Down
Loading

0 comments on commit ce77eac

Please sign in to comment.