From d95e62625b52e7feab689e7243fc835e888ced0b Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Mon, 23 Oct 2023 17:42:06 -0400 Subject: [PATCH] Update tests for jwst/roman --- tests/test_jwst.py | 28 ++++++++++++++++++++++++++++ tests/test_protocols.py | 15 --------------- tests/test_roman.py | 29 +++++++++++++++++++++++++++++ tox.ini | 4 ++-- 4 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 tests/test_jwst.py create mode 100644 tests/test_roman.py diff --git a/tests/test_jwst.py b/tests/test_jwst.py new file mode 100644 index 00000000..193b05b6 --- /dev/null +++ b/tests/test_jwst.py @@ -0,0 +1,28 @@ +""" +Integration tests with JWST pipeline +""" + +from inspect import getmembers, isclass + +import pytest + +from stpipe.protocols import DataModel, ModelContainer + +datamodels = pytest.importorskip("stdatamodels.jwst.datamodels") + + +@pytest.mark.parametrize( + "model", + [ + model[1] + for model in getmembers(datamodels, isclass) + if issubclass(model[1], datamodels.JwstDataModel) + ], +) +def test_datamodel(model): + assert isinstance(model(), DataModel) + + +def test_model_container(): + jwst = pytest.importorskip("jwst.datamodels") + assert isinstance(jwst.ModelContainer(), ModelContainer) diff --git a/tests/test_protocols.py b/tests/test_protocols.py index 828d0801..0ea09216 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -8,21 +8,6 @@ from stpipe.protocols import DataModel, ModelContainer -def test_roman_datamodel(): - roman_datamodels = pytest.importorskip("roman_datamodels.datamodels") - import roman_datamodels.maker_utils as rutil - - roman_image_tree = rutil.mk_level2_image() - image_model = roman_datamodels.ImageModel(roman_image_tree) - assert isinstance(image_model, DataModel) - - -def test_jwst_datamodel(): - jwst_datamodel = pytest.importorskip("stdatamodels.jwst.datamodels") - image_model = jwst_datamodel.ImageModel() - assert isinstance(image_model, DataModel) - - def _base_methods(): def crds_observatory(self): pass diff --git a/tests/test_roman.py b/tests/test_roman.py new file mode 100644 index 00000000..71d85138 --- /dev/null +++ b/tests/test_roman.py @@ -0,0 +1,29 @@ +""" +Integration tests with JWST pipeline +""" + +from inspect import getmembers, isclass + +import pytest + +from stpipe.protocols import DataModel, ModelContainer + +datamodels = pytest.importorskip("roman_datamodels.datamodels") + + +@pytest.mark.parametrize( + "model", + [ + model[1] + for model in getmembers(datamodels, isclass) + if model[1] != datamodels.DataModel + and issubclass(model[1], datamodels.DataModel) + ], +) +def test_datamodel(model): + assert isinstance(model(), DataModel) + + +def test_model_container(): + romancal = pytest.importorskip("romancal.datamodels") + assert isinstance(romancal.ModelContainer(), ModelContainer) diff --git a/tox.ini b/tox.ini index edfac95a..a8f8835a 100644 --- a/tox.ini +++ b/tox.ini @@ -71,8 +71,8 @@ commands = pytest \ warnings: -W error \ xdist: -n auto \ - jwst: --pyargs jwst --ignore-glob=timeconversion --ignore-glob=associations --ignore-glob=*/scripts/* \ - romancal: --pyargs romancal \ + jwst: tests/test_jwst.py --pyargs jwst --ignore-glob=timeconversion --ignore-glob=associations --ignore-glob=*/scripts/* \ + romancal: tests/test_roman.py --pyargs romancal \ cov: --cov=src/stpipe --cov-config=pyproject.toml --cov-report=term-missing --cov-report=xml \ {posargs}