Coverage for tests / test_visit_geometry.py: 38%

19 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-09 01:26 -0800

1# This file is part of obs_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22import unittest 

23 

24from lsst.obs.base.visit_geometry import VisitGeometry 

25from lsst.pipe.base.tests.mocks import InMemoryRepo 

26 

27 

28class VisitGeometryTestCase(unittest.TestCase): 

29 """Tests for VisitGeometry.""" 

30 

31 def setUp(self): 

32 self.repo: InMemoryRepo = self.enterContext(InMemoryRepo("base.yaml", "spatial.yaml")) 

33 

34 def test_round_trip(self): 

35 """Test round-tripping through a JSON string.""" 

36 (visit_record,) = self.repo.butler.query_dimension_records("visit", visit=1, instrument="Cam1") 

37 visit_detector_region_records = self.repo.butler.query_dimension_records( 

38 "visit_detector_region", visit=1, instrument="Cam1" 

39 ) 

40 vg1 = VisitGeometry( 

41 boresight_ra=45.0, 

42 boresight_dec=60.0, 

43 orientation=30.0, 

44 visit_region=visit_record.region, 

45 detector_regions={r.detector: r.region for r in visit_detector_region_records}, 

46 ) 

47 json_data = vg1.model_dump_json() 

48 vg2 = VisitGeometry.model_validate_json(json_data) 

49 self.assertEqual(vg1.boresight_ra, vg2.boresight_ra) 

50 self.assertEqual(vg1.boresight_dec, vg2.boresight_dec) 

51 self.assertEqual(vg1.orientation, vg2.orientation) 

52 self.assertEqual(vg1.visit_region, vg2.visit_region) 

53 self.assertEqual(vg1.detector_regions, vg2.detector_regions) 

54 

55 

56if __name__ == "__main__": 56 ↛ 57line 56 didn't jump to line 57 because the condition on line 56 was never true

57 unittest.main()