Example #1
0
 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)}, 
                                {}))
Example #2
0
 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)}, 
                               {}))
Example #3
0
 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)
     }, {}))
Example #4
0
 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)
     }, {}))
Example #5
0
 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)}))
Example #6
0
 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)
     }))
Example #7
0
 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)])
Example #8
0
 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)
     ])