Coverage for tests/testScheduledDowntimeData.py : 33%

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
self.th = Time('2020-01-01', format='isot', scale='tai') self.startofnight = -0.34 self.downtime_db = os.path.join(getPackageDir('sims_downtimeModel'), 'data', 'scheduled_downtime.db')
downtimeData = ScheduledDowntimeData(self.th, start_of_night_offset=self.startofnight) self.assertEqual(downtimeData.scheduled_downtime_db, self.downtime_db) self.assertEqual(self.th + TimeDelta(self.startofnight, format='jd'), downtimeData.night0) downtimeData = ScheduledDowntimeData(self.th, start_of_night_offset=0) self.assertEqual(downtimeData.night0, self.th)
downtimeData = ScheduledDowntimeData(self.th, start_of_night_offset=self.startofnight) downtimeData.read_data() self.assertEqual(len(downtimeData.downtime), 31) # Check some of the downtime values. dnight = downtimeData.downtime['end'] - downtimeData.downtime['start'] self.assertEqual(dnight[0].jd, 7) self.assertEqual(downtimeData.downtime['activity'][0], 'general maintenance') self.assertEqual(dnight[4].jd, 14) self.assertEqual(downtimeData.downtime['activity'][4], 'recoat mirror')
with getTempFilePath('.alt_downtime.db') as tmpdb: downtime_table = [] downtime_table.append("night INTEGER PRIMARY KEY") downtime_table.append("duration INTEGER") downtime_table.append("activity TEXT")
with sqlite3.connect(tmpdb) as conn: cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS Downtime") cur.execute("CREATE TABLE Downtime({})".format(",".join(downtime_table))) cur.execute("INSERT INTO Downtime VALUES(?, ?, ?)", (100, 7, "something to do")) cur.close()
downtimeData = ScheduledDowntimeData(self.th, scheduled_downtime_db=tmpdb, start_of_night_offset = self.startofnight) downtimeData.read_data() self.assertEqual(len(downtimeData.downtime), 1) self.assertEqual(downtimeData.downtime['activity'][0], 'something to do')
downtimeData = ScheduledDowntimeData(self.th, start_of_night_offset=self.startofnight) downtimeData.read_data() downtimes = downtimeData() self.assertEqual(downtimes['activity'][4], 'recoat mirror')
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |