def testCreateAlarmIndex2(self): # test alarm 5 min after result = createItems.createAlarmIndex('a0.5:100', [0,1,2,3], [0,1,2,3,4,5], self.tzinfo) self.assertEqual(result, ({0: datetime.timedelta(0, 300), 1: datetime.timedelta(0, 300), 2: datetime.timedelta(0, 300), 3: datetime.timedelta(0, 300)}, {}))
def testCreateAlarmIndex1(self): # test alarm 5 min before result = createItems.createAlarmIndex('b0.5:100', [0,1,2,3], [0,1,2,3,4,5], self.tzinfo) self.assertEqual(result, ({0: datetime.timedelta(-1, 86100), 1: datetime.timedelta(-1, 86100), 2: datetime.timedelta(-1, 86100), 3: datetime.timedelta(-1, 86100)}, {}))
def testCreateAlarmIndex2(self): # test alarm 5 min after result = createItems.createAlarmIndex('a0.5:100', [0, 1, 2, 3], [0, 1, 2, 3, 4, 5], self.tzinfo) self.assertEqual(result, ({ 0: datetime.timedelta(0, 300), 1: datetime.timedelta(0, 300), 2: datetime.timedelta(0, 300), 3: datetime.timedelta(0, 300) }, {}))
def testCreateAlarmIndex1(self): # test alarm 5 min before result = createItems.createAlarmIndex('b0.5:100', [0, 1, 2, 3], [0, 1, 2, 3, 4, 5], self.tzinfo) self.assertEqual(result, ({ 0: datetime.timedelta(-1, 86100), 1: datetime.timedelta(-1, 86100), 2: datetime.timedelta(-1, 86100), 3: datetime.timedelta(-1, 86100) }, {}))
def testCreateAlarmIndex3(self): # test custom alarm 5:05 PM result = createItems.createAlarmIndex('c17.5:100', [0,1,2,3], [0,1,2,3,4,5], self.tzinfo) self.assertEqual(result, ({}, {0: datetime.time(17, 5, 0, 0, self.tzinfo), 1: datetime.time(17, 5, 0, 0, self.tzinfo), 2: datetime.time(17, 5, 0, 0, self.tzinfo), 3: datetime.time(17, 5, 0, 0, self.tzinfo), 4: datetime.time(17, 5, 0, 0, self.tzinfo), 5: datetime.time(17, 5, 0, 0, self.tzinfo)}))
def testCreateAlarmIndex3(self): # test custom alarm 5:05 PM result = createItems.createAlarmIndex('c17.5:100', [0, 1, 2, 3], [0, 1, 2, 3, 4, 5], self.tzinfo) self.assertEqual(result, ({}, { 0: datetime.time(17, 5, 0, 0, self.tzinfo), 1: datetime.time(17, 5, 0, 0, self.tzinfo), 2: datetime.time(17, 5, 0, 0, self.tzinfo), 3: datetime.time(17, 5, 0, 0, self.tzinfo), 4: datetime.time(17, 5, 0, 0, self.tzinfo), 5: datetime.time(17, 5, 0, 0, self.tzinfo) }))
def testCreateAlarmIndex4(self): # test spec combining all types result = createItems.createAlarmIndex('b0.5:30, a0.5:30, c17.5:40', [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], self.tzinfo) r0 = result[0].values() r0.sort() r1 = result[1].values() self.assertEqual(r0, [datetime.timedelta(-1, 86100), datetime.timedelta(0, 300)]) self.assertEqual(r1, [datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo)])
def testCreateAlarmIndex4(self): # test spec combining all types result = createItems.createAlarmIndex('b0.5:30, a0.5:30, c17.5:40', [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], self.tzinfo) r0 = result[0].values() r0.sort() r1 = result[1].values() self.assertEqual( r0, [datetime.timedelta(-1, 86100), datetime.timedelta(0, 300)]) self.assertEqual(r1, [ datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo), datetime.time(17, 5, 0, 0, self.tzinfo) ])