Skip to content

Commit 3c07c6a

Browse files
Fix the broken tests
1 parent 618910c commit 3c07c6a

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/roman_datamodels/maker_utils/_datamodels.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ def mk_source_catalog(*, filepath=None, **kwargs):
448448
roman_datamodels.stnode.SourceCatalog
449449
"""
450450
source_catalog = stnode.SourceCatalog()
451-
source_catalog["meta"] = kwargs.get("meta", {})
452-
source_catalog["source_catalog"] = kwargs.get("source_catalog", Table())
451+
# There currently is no meta attribute for SourceCatalog
452+
# This is likely to change once metadata has been added
453+
# source_catalog["meta"] = kwargs.get("meta", {})
454+
source_catalog["source_catalog"] = kwargs.get("source_catalog", Table([range(3), range(3)], names=["a", "b"]))
453455

454456
return save_node(source_catalog, filepath=filepath)

src/roman_datamodels/testing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
from asdf.tags.core import NDArrayType
44
from astropy.modeling import Model
5+
from astropy.table import Table
56
from numpy.testing import assert_array_equal
67

78
from .stnode import DNode, TaggedListNode, TaggedObjectNode, TaggedScalarNode
@@ -57,6 +58,8 @@ def _assert_value_equal(value1, value2):
5758
assert_array_equal(value1, value2)
5859
elif isinstance(value1, Model):
5960
assert_model_equal(value1, value2)
61+
elif isinstance(value1, Table):
62+
assert (value1 == value2).all()
6063
elif isinstance(value1, gwcs.WCS):
6164
return True
6265
else:

tests/test_models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from asdf.exceptions import ValidationError
88
from astropy import units as u
99
from astropy.modeling import Model
10-
from astropy.table import QTable
10+
from astropy.table import QTable, Table
1111
from numpy.testing import assert_array_equal
1212

1313
from roman_datamodels import datamodels
@@ -707,6 +707,14 @@ def test_append_individual_image_meta_level3_mosaic():
707707
assert wfi_mosaic_model.meta.individual_image_meta.program["pi_name"][2] == "Roman"
708708

709709

710+
# source catalog tests
711+
def test_make_source_catalog():
712+
source_catalog = utils.mk_source_catalog()
713+
source_catalog_model = datamodels.SourceCatalogModel(source_catalog)
714+
715+
assert isinstance(source_catalog_model.source_catalog, Table)
716+
717+
710718
def test_datamodel_info_search(capsys):
711719
wfi_science_raw = utils.mk_level1_science_raw(shape=(2, 8, 8))
712720
af = asdf.AsdfFile()

tests/test_open.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def test_node_round_trip(tmp_path, node_class):
226226
@pytest.mark.filterwarnings("ignore:This function assumes shape is 2D")
227227
@pytest.mark.filterwarnings("ignore:Input shape must be 5D")
228228
def test_opening_model(tmp_path, node_class):
229+
if node_class == stnode.SourceCatalog:
230+
pytest.xfail("SourceCatalog does not have a meta attribute yet")
231+
229232
file_path = tmp_path / "test.asdf"
230233

231234
# Create a node and write it to disk

0 commit comments

Comments
 (0)