From 912301069dbf2b780f288859b1a8d3cfecabe32a Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Tue, 29 Oct 2024 09:33:03 -0400 Subject: [PATCH] remove duplicate test module --- tests/{ => validation}/test_schemas.py | 2 +- tests/validation/test_vrs_schema.py | 65 -------------------------- 2 files changed, 1 insertion(+), 66 deletions(-) rename tests/{ => validation}/test_schemas.py (98%) delete mode 100644 tests/validation/test_vrs_schema.py diff --git a/tests/test_schemas.py b/tests/validation/test_schemas.py similarity index 98% rename from tests/test_schemas.py rename to tests/validation/test_schemas.py index b648c7cf..87c588ac 100644 --- a/tests/test_schemas.py +++ b/tests/validation/test_schemas.py @@ -51,7 +51,7 @@ def _update_gks_schema_mapping( GKS_SCHEMA_MAPPING = {gks: GKSSchemaMapping() for gks in GKSSchema} -SUBMODULES_DIR = Path(__file__).parents[1] / "submodules" / "vrs" +SUBMODULES_DIR = Path(__file__).parents[2] / "submodules" / "vrs" # Get vrs classes diff --git a/tests/validation/test_vrs_schema.py b/tests/validation/test_vrs_schema.py deleted file mode 100644 index a42853a4..00000000 --- a/tests/validation/test_vrs_schema.py +++ /dev/null @@ -1,65 +0,0 @@ -"""test that VRS Python model structures match VRS Schema -""" -import json -from pathlib import Path - -from ga4gh.vrs import models - -ROOT_DIR = Path(__file__).parents[2] -VRS_SCHEMA_DIR = ROOT_DIR / 'submodules' / 'vrs' / 'schema' / 'vrs' / 'json' -VRS_SCHEMA = {} - -VRS_CONCRETE_CLASSES = set() -VRS_PRIMITIVES = set() - -for f in VRS_SCHEMA_DIR.glob("*"): - with open(f, "r") as rf: - cls_def = json.load(rf) - - vrs_class = cls_def["title"] - VRS_SCHEMA[vrs_class] = cls_def - if "properties" in cls_def: - VRS_CONCRETE_CLASSES.add(vrs_class) - elif cls_def.get("type") in {"array", "int", "str"}: - VRS_PRIMITIVES.add(vrs_class) - - -NOT_IMPLEMENTED = ['Adjacency', 'Haplotype'] # Use this to skip testing of not-implemented classes - # TODO: Remove this once 2.0 models at beta - - -def test_schema_models_exist(): - """test that VRS Python covers the models defined by VRS - """ - for vrs_class in VRS_CONCRETE_CLASSES | VRS_PRIMITIVES: - if vrs_class in NOT_IMPLEMENTED: - continue - assert getattr(models, vrs_class, False) - - -def test_schema_class_fields_are_valid(): - """test that VRS Python model fields match the VRS specification - """ - for vrs_class in VRS_CONCRETE_CLASSES: - if vrs_class in NOT_IMPLEMENTED: - continue - schema_fields = set(VRS_SCHEMA[vrs_class]['properties']) - pydantic_model = getattr(models, vrs_class) - assert set(pydantic_model.model_fields) == schema_fields, vrs_class - - -def test_model_keys_are_valid(): - """test that digest keys on Value Objects are valid and sorted - """ - for vrs_class in VRS_CONCRETE_CLASSES: - if vrs_class in NOT_IMPLEMENTED: - continue - if VRS_SCHEMA[vrs_class].get('ga4ghDigest', {}).get('keys', None) is None: - continue - pydantic_model = getattr(models, vrs_class) - try: - pydantic_model_digest_keys = pydantic_model.ga4gh.keys - except AttributeError: - raise AttributeError(vrs_class) - assert set(pydantic_model_digest_keys) == set(VRS_SCHEMA[vrs_class]['ga4ghDigest']['keys']), vrs_class - assert pydantic_model_digest_keys == sorted(pydantic_model.ga4gh.keys), vrs_class