Coverage for tests / test_utils.py: 50%
26 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:47 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:47 +0000
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
24import unittest
26import astropy
27import pydantic
29import lsst.daf.butler as dafButler
30import lsst.pipe.base as pipeBase
31import lsst.sphgeom as sphgeom
32import lsst.utils.tests
35class RegionTimeInfoTestCase(unittest.TestCase):
36 """Unit tests for lsst.pipe.base.utils.RegionTimeInfo.
38 Since RegionTimeInfo is a passive container that exists only for
39 serialization convenience, the tests only cover serialization and assume
40 e.g. input validation is handled by the component types.
41 """
43 def setUp(self):
44 self.region = sphgeom.Circle(
45 sphgeom.UnitVector3d(sphgeom.Angle.fromDegrees(34.5), sphgeom.Angle.fromDegrees(-42.0)),
46 sphgeom.Angle.fromDegrees(1.0),
47 )
48 self.times = dafButler.Timespan(
49 begin=astropy.time.Time("2013-06-17 13:34:45.775000", scale="tai", format="iso"),
50 end=astropy.time.Time("2013-06-17 13:35:17.947000", scale="tai", format="iso"),
51 )
53 def test_init(self):
54 # Both parameters are mandatory
55 with self.assertRaises(ValueError):
56 pipeBase.utils.RegionTimeInfo()
57 with self.assertRaises(ValueError):
58 pipeBase.utils.RegionTimeInfo(region=self.region)
59 with self.assertRaises(ValueError):
60 pipeBase.utils.RegionTimeInfo(timespan=self.times)
62 def test_serialization(self):
63 original = pipeBase.utils.RegionTimeInfo(region=self.region, timespan=self.times)
64 adapter = pydantic.TypeAdapter(pipeBase.utils.RegionTimeInfo)
66 roundtripped = adapter.validate_json(adapter.dump_json(original))
67 self.assertEqual(roundtripped, original)
70class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
71 """Run file leak tests."""
74def setup_module(module):
75 """Configure pytest."""
76 lsst.utils.tests.init()
79if __name__ == "__main__":
80 lsst.utils.tests.init()
81 unittest.main()