Skip to content

Commit

Permalink
ruff cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Oct 29, 2024
1 parent 9123010 commit 9e78fca
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/validation/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GKSSchemaMapping(BaseModel):
base_classes: set = set()
concrete_classes: set = set()
primitives: set = set()
schema: dict = dict()
schema: dict = {}


def _update_gks_schema_mapping(
Expand Down Expand Up @@ -71,7 +71,7 @@ def _update_gks_schema_mapping(


@pytest.mark.parametrize(
"gks_schema,pydantic_models",
("gks_schema", "pydantic_models"),
[
(GKSSchema.VRS, vrs_models),
(GKSSchema.CORE_IM, entity_models),
Expand All @@ -88,7 +88,7 @@ def test_schema_models_in_pydantic(gks_schema, pydantic_models):


@pytest.mark.parametrize(
"gks_schema,pydantic_models",
("gks_schema", "pydantic_models"),
[
(GKSSchema.VRS, vrs_models),
(GKSSchema.CORE_IM, entity_models),
Expand All @@ -107,20 +107,20 @@ def test_schema_class_fields(gks_schema, pydantic_models):

required_schema_fields = set(mapping.schema[schema_model]["required"])

for property, property_def in schema_properties.items():
pydantic_model_field_info = pydantic_model.model_fields[property]
for prop, property_def in schema_properties.items():
pydantic_model_field_info = pydantic_model.model_fields[prop]
pydantic_field_required = pydantic_model_field_info.is_required()

if property in required_schema_fields:
if property != "type":
assert pydantic_field_required, f"{pydantic_model}.{property}"
if prop in required_schema_fields:
if prop != "type":
assert pydantic_field_required, f"{pydantic_model}.{prop}"
else:
assert not pydantic_field_required, f"{pydantic_model}.{property}"
assert not pydantic_field_required, f"{pydantic_model}.{prop}"

if "description" in property_def:
assert property_def["description"].replace("'", "\"") == pydantic_model_field_info.description.replace("'", "\""), f"{pydantic_model}.{property}"
assert property_def["description"].replace("'", "\"") == pydantic_model_field_info.description.replace("'", "\""), f"{pydantic_model}.{prop}"
else:
assert pydantic_model_field_info.description is None, f"{pydantic_model}.{property}"
assert pydantic_model_field_info.description is None, f"{pydantic_model}.{prop}"


def test_ga4gh_keys():
Expand Down

0 comments on commit 9e78fca

Please sign in to comment.