Coverage for tests/test_translator.py: 52%

15 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-15 04:07 -0700

1# This file is part of obs_rubinGenericCamera. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://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 os.path 

23import unittest 

24import astropy.units as u 

25from lsst.obs.rubinGenericCamera.translator import StarTrackerNarrowTranslator, \ 

26 StarTrackerWideTranslator, StarTrackerFastTranslator # noqa: F401 -- register the translators 

27 

28from astro_metadata_translator.tests import MetadataAssertHelper 

29 

30TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

31 

32 

33class RubinGenericCameraMetadataTranslatorTestCase(unittest.TestCase, MetadataAssertHelper): 

34 """Each test reads in raw headers from YAML files, constructs an 

35 `ObservationInfo`, and compares the properties with the expected values 

36 defined in the corresponding `dict`.""" 

37 

38 datadir = os.path.join(TESTDIR, "headers") 

39 

40 def test_comCam_translator(self): 

41 test_data = [ 

42 ("GC101_O_20221208_000211.yaml", 

43 dict(telescope="Simonyi Survey Telescope", 

44 instrument="StarTrackerWide", 

45 boresight_rotation_coord="sky", 

46 dark_time=5.0 * u.s, 

47 detector_group="None", 

48 detector_name="AlliedVision GT3300", 

49 detector_num=0, 

50 detector_serial="00:0f:31:03:60:c2", 

51 exposure_id=2022120800211, 

52 exposure_group="2022-12-09T05:20:47.840", 

53 exposure_time=5.0 * u.s, 

54 group_counter_start=212, 

55 group_counter_end=212, 

56 object="UNKNOWN", 

57 observation_counter=211, 

58 observation_id="GC101_O_20221208_000211", 

59 observation_type="OBJECT", 

60 observation_reason="lvv-t2730 lvv-exxxx", 

61 observing_day=20221208, 

62 physical_filter="empty", 

63 pressure=None, 

64 relative_humidity=None, 

65 science_program="", 

66 temperature=None, 

67 )), 

68 ("GC102_O_20221208_000211.yaml", 

69 dict(telescope="Simonyi Survey Telescope", 

70 instrument="StarTrackerNarrow", 

71 boresight_rotation_coord="sky", 

72 dark_time=3.0 * u.s, 

73 detector_group="None", 

74 detector_name="AlliedVision GT3400", 

75 detector_num=0, 

76 detector_serial="00:0f:31:03:ae:60", 

77 exposure_id=2022120800211, 

78 exposure_group="2022-12-09T05:20:47.841", 

79 exposure_time=3.0 * u.s, 

80 group_counter_start=212, 

81 group_counter_end=212, 

82 object="UNKNOWN", 

83 observation_counter=211, 

84 observation_id="GC102_O_20221208_000211", 

85 observation_type="OBJECT", 

86 observation_reason="lvv-t2730 lvv-exxxx", 

87 observing_day=20221208, 

88 physical_filter="empty", 

89 pressure=None, 

90 relative_humidity=None, 

91 science_program="", 

92 temperature=None, 

93 )), 

94 ("GC103_O_20221208_000211.yaml", 

95 dict(telescope="Simonyi Survey Telescope", 

96 instrument="StarTrackerFast", 

97 boresight_rotation_coord="sky", 

98 dark_time=0.1 * u.s, 

99 detector_group="None", 

100 detector_name="AlliedVision GC650M", 

101 detector_num=0, 

102 detector_serial="00:0F:31:03:3F:BA", 

103 exposure_id=2022120800211, 

104 exposure_group="2022-12-09T05:20:47.842", 

105 exposure_time=0.1 * u.s, 

106 group_counter_start=212, 

107 group_counter_end=212, 

108 object="UNKNOWN", 

109 observation_counter=211, 

110 observation_id="GC103_O_20221208_000211", 

111 observation_type="OBJECT", 

112 observation_reason="lvv-t2730 lvv-exxxx", 

113 observing_day=20221208, 

114 physical_filter="empty", 

115 pressure=None, 

116 relative_humidity=None, 

117 science_program="", 

118 temperature=None, 

119 )), 

120 ] 

121 for filename, expected in test_data: 

122 with self.subTest(f"Testing {filename}"): 

123 self.assertObservationInfoFromYaml(filename, dir=self.datadir, **expected) 

124 

125 

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

127 unittest.main()