Coverage for tests/test_instrument.py: 52%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2023-03-12 01:53 -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 

22"""Tests of the Instrument class. 

23""" 

24 

25import datetime 

26import unittest 

27 

28from lsst.obs.base import Instrument 

29from lsst.obs.base.instrument_tests import InstrumentTests, InstrumentTestData, DummyCam 

30 

31 

32class InstrumentTestCase(InstrumentTests, unittest.TestCase): 

33 """Test for Instrument. 

34 """ 

35 

36 instrument = DummyCam() 

37 

38 data = InstrumentTestData(name="DummyCam", 

39 nDetectors=2, 

40 firstDetectorName="RXX_S00", 

41 physical_filters={"dummy_g", "dummy_u"}) 

42 

43 def test_getCamera(self): 

44 """No camera defined in DummyCam""" 

45 return 

46 

47 def test_collectionTimestamps(self): 

48 self.assertEqual( 

49 Instrument.formatCollectionTimestamp("2018-05-03"), 

50 "20180503T000000Z", 

51 ) 

52 self.assertEqual( 

53 Instrument.formatCollectionTimestamp("2018-05-03T14:32:16"), 

54 "20180503T143216Z", 

55 ) 

56 self.assertEqual( 

57 Instrument.formatCollectionTimestamp("20180503T143216Z"), 

58 "20180503T143216Z", 

59 ) 

60 self.assertEqual( 

61 Instrument.formatCollectionTimestamp(datetime.datetime(2018, 5, 3, 14, 32, 16)), 

62 "20180503T143216Z", 

63 ) 

64 formattedNow = Instrument.makeCollectionTimestamp() 

65 self.assertIsInstance(formattedNow, str) 

66 datetimeThen1 = datetime.datetime.strptime(formattedNow, "%Y%m%dT%H%M%S%z") 

67 self.assertEqual(datetimeThen1.tzinfo, datetime.timezone.utc) 

68 

69 

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

71 unittest.main()