From 8702d8ca89eefe7a9e284a1a84a72647de60962c Mon Sep 17 00:00:00 2001 From: Shyam D Date: Tue, 20 Oct 2020 19:10:44 -0700 Subject: [PATCH] move vasp tasks and test for sandboxing --- .../vasp/{test_vasp_calcs.py => test_vasp.py} | 33 ++++++++++++++++++- tests/emmet-core/vasp/test_vasp_validation.py | 21 ------------ 2 files changed, 32 insertions(+), 22 deletions(-) rename tests/emmet-core/vasp/{test_vasp_calcs.py => test_vasp.py} (51%) delete mode 100644 tests/emmet-core/vasp/test_vasp_validation.py diff --git a/tests/emmet-core/vasp/test_vasp_calcs.py b/tests/emmet-core/vasp/test_vasp.py similarity index 51% rename from tests/emmet-core/vasp/test_vasp_calcs.py rename to tests/emmet-core/vasp/test_vasp.py index 1a78eba94c..6df7568b69 100644 --- a/tests/emmet-core/vasp/test_vasp_calcs.py +++ b/tests/emmet-core/vasp/test_vasp.py @@ -1,4 +1,13 @@ -from emmet.core.vasp.calc_types import run_type, task_type, RunType, TaskType +import json + +import pytest +from maggma.stores import JSONStore, MemoryStore +from monty.io import zopen + +from emmet.core import SETTINGS +from emmet.core.vasp.calc_types import RunType, TaskType, run_type, task_type +from emmet.core.vasp.task import TaskDocument +from emmet.core.vasp.validation import ValidationDoc def test_task_tye(): @@ -30,3 +39,25 @@ def test_run_type(): for _type, params in params_sets: assert run_type(params) == RunType(_type) + + +@pytest.fixture(scope="session") +def tasks(test_dir): + with zopen(test_dir / "test_si_tasks.json.gz") as f: + data = json.load(f) + + return [TaskDocument(**d) for d in data] + + +def test_validator(tasks): + validation_docs = [ValidationDoc.from_task_doc(task) for task in tasks] + + assert len(validation_docs) == len(tasks) + assert all(doc.valid for doc in validation_docs) + + +def test_sandboxing(): + + SETTINGS.TAGS_TO_SANDBOXES = {"test_sbx": ["test"]} + test_doc = TaskDocument(task_id="test", tags=["test"]) + assert test_doc.sandboxes == ["test_sbx"] diff --git a/tests/emmet-core/vasp/test_vasp_validation.py b/tests/emmet-core/vasp/test_vasp_validation.py deleted file mode 100644 index d8d1e29ef0..0000000000 --- a/tests/emmet-core/vasp/test_vasp_validation.py +++ /dev/null @@ -1,21 +0,0 @@ -import pytest -import json -from maggma.stores import JSONStore, MemoryStore -from emmet.core.vasp.validation import ValidationDoc -from emmet.core.vasp.task import TaskDocument -from monty.io import zopen - - -@pytest.fixture(scope="session") -def tasks(test_dir): - with zopen(test_dir / "test_si_tasks.json.gz") as f: - data = json.load(f) - - return [TaskDocument(**d) for d in data] - - -def test_validator(tasks): - validation_docs = [ValidationDoc.from_task_doc(task) for task in tasks] - - assert len(validation_docs) == len(tasks) - assert all(doc.valid for doc in validation_docs)