From 9976131bd5d48588c5c0af6deda215d280425702 Mon Sep 17 00:00:00 2001 From: Jason Munro Date: Fri, 9 Jun 2023 16:10:34 -0700 Subject: [PATCH] Fix molecules summary tests --- mp_api/client/core/utils.py | 10 +++------- tests/molecules/test_summary.py | 24 +++++++----------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/mp_api/client/core/utils.py b/mp_api/client/core/utils.py index 489e914e..93701122 100644 --- a/mp_api/client/core/utils.py +++ b/mp_api/client/core/utils.py @@ -19,7 +19,7 @@ def validate_ids(id_list: List[str]): Returns: id_list: Returns original ID list if everything is formatted correctly. """ - pattern = "(mp|mvc|mol)-.*" + pattern = "(mp|mvc|mol|mpcule)-.*" for entry in id_list: if re.match(pattern, entry) is None: @@ -43,9 +43,7 @@ def api_sanitize( fields_to_leave: list of strings for model fields as "model__name__.field" """ models = [ - model - for model in get_flat_models_from_model(pydantic_model) - if issubclass(model, BaseModel) + model for model in get_flat_models_from_model(pydantic_model) if issubclass(model, BaseModel) ] # type: List[Type[BaseModel]] fields_to_leave = fields_to_leave or [] @@ -94,9 +92,7 @@ def validate_monty(cls, v): errors.append("@class") if len(errors) > 0: - raise ValueError( - "Missing Monty seriailzation fields in dictionary: {errors}" - ) + raise ValueError("Missing Monty seriailzation fields in dictionary: {errors}") return v else: diff --git a/tests/molecules/test_summary.py b/tests/molecules/test_summary.py index ff949c12..9c846e54 100644 --- a/tests/molecules/test_summary.py +++ b/tests/molecules/test_summary.py @@ -6,37 +6,26 @@ from mp_api.client.routes.molecules.summary import MoleculesSummaryRester -excluded_params = [ - "sort_fields", - "chunk_size", - "num_chunks", - "all_fields", - "fields", - "has_solvent", - "exclude_elements", - # Below: currently timing out - "nelements", - "has_props", -] +excluded_params = ["sort_fields", "chunk_size", "num_chunks", "all_fields", "fields", "exclude_elements"] alt_name = {"formula": "formula_alphabetical", "molecule_ids": "molecule_id"} custom_field_tests = { - "molecule_ids": ["9f153b9f3caa3124fb404b42e4cf82c8-C2H4-0-1"], + "molecule_ids": ["351ef090ebd90b661a4e1205756f6957-C1Mg1N2O1S1-m2-1"], "formula": "C2 H4", "chemsys": "C-H", - "elements": ["C", "H"], + "elements": ["P"], "has_solvent": "DIELECTRIC=18,500;N=1,415;ALPHA=0,000;BETA=0,735;GAMMA=20,200;PHI=0,000;PSI=0,000", "has_level_of_theory": "wB97X-V/def2-TZVPPD/SMD", "has_lot_solvent": "wB97X-V/def2-TZVPPD/SMD(SOLVENT=THF)", "nelements": 2, + "charge": 1, + "spin_multiplicity": 1, "has_props": [HasProps.orbitals], } # type: dict -@pytest.mark.skipif( - os.environ.get("MP_API_KEY", None) is None, reason="No API key found." -) +@pytest.mark.skipif(os.environ.get("MP_API_KEY", None) is None, reason="No API key found.") def test_client(): search_method = MoleculesSummaryRester().search @@ -49,6 +38,7 @@ def test_client(): if param not in excluded_params: param_type = entry[1].__args__[0] q = None + print(param) if param in custom_field_tests: