From 7d49ac085632d86c4137755438003836855b4a84 Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Fri, 1 Nov 2024 14:34:18 -0700 Subject: [PATCH] Add test for dataset type serialization --- tests/test_dimensions.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_dimensions.py b/tests/test_dimensions.py index 3a7fe2b9f6..a613572e33 100644 --- a/tests/test_dimensions.py +++ b/tests/test_dimensions.py @@ -42,6 +42,7 @@ DataCoordinate, DataCoordinateSequence, DataCoordinateSet, + DatasetType, Dimension, DimensionConfig, DimensionElement, @@ -411,6 +412,19 @@ def testPickling(self): group2 = pickle.loads(pickle.dumps(group1)) self.assertIs(group1, group2) + def testSerialization(self): + # Check that dataset types round-trip correctly through serialization. + dataset_type = DatasetType( + "flat", + dimensions=["instrument", "detector", "physical_filter", "band"], + isCalibration=True, + universe=self.universe, + storageClass="int", + ) + roundtripped = DatasetType.from_simple(dataset_type.to_simple(), universe=self.universe) + + self.assertEqual(dataset_type, roundtripped) + @dataclass class SplitByStateFlags: