Coverage for tests/test_instrument.py: 52%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-14 20:02 +0000

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 DummyCam, InstrumentTestData, InstrumentTests 

30 

31 

32class InstrumentTestCase(InstrumentTests, unittest.TestCase): 

33 """Test for Instrument.""" 

34 

35 instrument = DummyCam() 

36 

37 data = InstrumentTestData( 

38 name="DummyCam", nDetectors=2, firstDetectorName="RXX_S00", physical_filters={"dummy_g", "dummy_u"} 

39 ) 

40 

41 def test_getCamera(self): 

42 """No camera defined in DummyCam""" 

43 return 

44 

45 def test_collectionTimestamps(self): 

46 self.assertEqual( 

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

48 "20180503T000000Z", 

49 ) 

50 self.assertEqual( 

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

52 "20180503T143216Z", 

53 ) 

54 self.assertEqual( 

55 Instrument.formatCollectionTimestamp("20180503T143216Z"), 

56 "20180503T143216Z", 

57 ) 

58 self.assertEqual( 

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

60 "20180503T143216Z", 

61 ) 

62 formattedNow = Instrument.makeCollectionTimestamp() 

63 self.assertIsInstance(formattedNow, str) 

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

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

66 

67 

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

69 unittest.main()