Coverage for tests/testUnscheduledDowntimeData.py : 34%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import unittest
2from astropy.time import Time, TimeDelta
3import lsst.utils.tests
5from lsst.sims.downtimeModel import UnscheduledDowntimeData
8class UnscheduledDowntimeDataTest(unittest.TestCase):
10 def setUp(self):
11 self.th = Time('2020-01-01', format='isot', scale='tai')
12 self.startofnight = -0.34
13 self.seed = 1516231120
14 self.survey_length = 3650*2
16 def test_basic_information_after_creation(self):
17 downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight,
18 survey_length=self.survey_length, seed=self.seed)
19 self.assertEqual(downtimeData.seed, self.seed)
20 self.assertEqual(downtimeData.survey_length, self.survey_length)
21 self.assertEqual(self.th + TimeDelta(self.startofnight, format='jd'), downtimeData.night0)
22 downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=0,
23 survey_length=self.survey_length, seed=self.seed)
24 self.assertEqual(downtimeData.night0, self.th)
26 def test_information_after_initialization(self):
27 downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight,
28 survey_length=self.survey_length, seed=self.seed)
29 downtimeData.make_data()
30 self.assertEqual(len(downtimeData.downtime), 155)
31 # Check some of the downtime values.
32 dnight = downtimeData.downtime['end'] - downtimeData.downtime['start']
33 self.assertEqual(dnight[0].jd, 1)
34 self.assertEqual(downtimeData.downtime['activity'][0], 'minor event')
35 self.assertEqual(dnight[2].jd, 7)
36 self.assertEqual(downtimeData.downtime['activity'][2], 'major event')
38 def test_alternate_seed(self):
39 downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight,
40 survey_length=self.survey_length, seed=3)
41 downtimeData.make_data()
42 self.assertEqual(len(downtimeData.downtime), 145)
44 def test_call(self):
45 downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight,
46 survey_length=self.survey_length, seed=self.seed)
47 downtimeData.make_data()
48 downtimes = downtimeData()
49 self.assertEqual(downtimes['activity'][2], 'major event')
52class TestMemory(lsst.utils.tests.MemoryTestCase):
53 pass
55def setup_module(module):
56 lsst.utils.tests.init()
58if __name__ == "__main__": 58 ↛ 59line 58 didn't jump to line 59, because the condition on line 58 was never true
59 lsst.utils.tests.init()
60 unittest.main()