Exemple #1
0
 def test_parse_EVENT_too_short(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23", self.telldus_library, 
         self.groups)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT", self.telldus_library, 
         self.groups)			
Exemple #2
0
 def test_parse_EVENT_dim(self):
     event = mas.parse_EVENT("EVENT 01:23 Sundown dim(5,50)",  
     self.telldus_library, self.groups)
     self.assertTrue(isinstance(event.function,
     mas.FunctionDim))
     self.assertTrue(event.function.devices == [5])
     self.assertTrue(event.function.dim_level == 50)
Exemple #3
0
 def test_weekday2(self):
     event = mas.parse_EVENT("EVENT 10:00 Mon/Sun on(1)",
                             self.telldus_library, self.groups, False)
     t_sunrise = datetime.time(10)
     t_sunset = datetime.time(18)
     # 2014-03-03 is a Monday
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 10, 0), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 4, 10, 0), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 5, 10, 0), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 6, 10, 0), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 7, 10, 0), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 8, 10, 0), t_sunrise,
                          t_sunset))
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 9, 10, 0), t_sunrise,
                          t_sunset))
Exemple #4
0
 def test_sunset_offset_trig_plus(self):
     event = mas.parse_EVENT("EVENT Sunset+4.1 on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(10) 
     t_sunset = datetime.time(18,4) 
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,22,10),
                     t_sunrise,t_sunset))
Exemple #5
0
 def test_sunrise_offset_trig_minus(self):
     event = mas.parse_EVENT("EVENT Sunrise-3.5 on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(4) 
     t_sunset = datetime.time(18) 
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,00,30),
                     t_sunrise,t_sunset))                      
Exemple #6
0
 def test_parse_EVENT_group_pass2(self):
     groups = mas.Groups()
     groups.add(mas.parse_GROUP('GROUP 1 "g1" 2 4 6'))
     groups.add(mas.parse_GROUP('GROUP 2 "g2" 3'))
     groups.add(mas.parse_GROUP('GROUP 3 "g3" 1 7'))
     event = mas.parse_EVENT("EVENT 01:23 Sundown on(G2)",
                             self.telldus_library, groups)
     self.assertTrue(event.function.devices == [3])
Exemple #7
0
 def test_sunset_offset_trig_plus(self):
     event = mas.parse_EVENT("EVENT Sunset+4.1 on(1)", self.telldus_library,
                             self.groups, True)
     t_sunrise = datetime.time(10)
     t_sunset = datetime.time(18, 4)
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 22, 10), t_sunrise,
                          t_sunset))
Exemple #8
0
 def test_parse_EVENT_group_pass2(self):
     groups = mas.Groups()
     groups.add(mas.parse_GROUP('GROUP 1 "g1" 2 4 6'))
     groups.add(mas.parse_GROUP('GROUP 2 "g2" 3'))
     groups.add(mas.parse_GROUP('GROUP 3 "g3" 1 7'))
     event = mas.parse_EVENT("EVENT 01:23 Sundown on(G2)",  
     self.telldus_library, groups)
     self.assertTrue(event.function.devices == [3])
Exemple #9
0
 def test_sunrise_offset_trig_minus(self):
     event = mas.parse_EVENT("EVENT Sunrise-3.5 on(1)",
                             self.telldus_library, self.groups, True)
     t_sunrise = datetime.time(4)
     t_sunset = datetime.time(18)
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 00, 30), t_sunrise,
                          t_sunset))
Exemple #10
0
 def test_parse_EVENT_off(self):
     event = mas.parse_EVENT("EVENT 01:23 Sunup off(1)",
                             self.telldus_library, self.groups)
     self.assertTrue(event.hour == 1)
     self.assertTrue(event.minute == 23)
     self.assertTrue(event.restriction == mas.TimeEvent.RESTRICTION_SUNUP)
     self.assertTrue(isinstance(event.function, mas.FunctionOff))
     self.assertTrue(event.function.devices == [1])
Exemple #11
0
 def test_sunrise_offset_trig_plus(self):
     event = mas.parse_EVENT("EVENT Sunrise+3.5 on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(10,1) 
     t_sunset = datetime.time(18) 
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,10,00),
                     t_sunrise,t_sunset))
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,13,31),
                     t_sunrise,t_sunset))
Exemple #12
0
 def test_sunset_offset_trig_minus(self):
     event = mas.parse_EVENT("EVENT Sunset-0.2 on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(10) 
     t_sunset = datetime.time(18) 
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,17,48),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,18,00),
                     t_sunrise,t_sunset))
Exemple #13
0
 def test_sunset_offset_trig_over_day(self):
     event = mas.parse_EVENT("EVENT Sunset+3 on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(1) 
     t_sunset = datetime.time(22) 
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,22,00),
                     t_sunrise,t_sunset))
     self.assertTrue(event.time_match(datetime.datetime(2014,3,4,1,00),
                     t_sunrise,t_sunset))
Exemple #14
0
 def test_parse_EVENT_off(self):
     event = mas.parse_EVENT("EVENT 01:23 Sunup off(1)", 
     self.telldus_library, self.groups)
     self.assertTrue(event.hour == 1)
     self.assertTrue(event.minute == 23)
     self.assertTrue(event.restriction == 
     mas.TimeEvent.RESTRICTION_SUNUP)
     self.assertTrue(isinstance(event.function,
     mas.FunctionOff))
     self.assertTrue(event.function.devices == [1])
Exemple #15
0
 def test_parse_EVENT_sunset(self):
     event = mas.parse_EVENT("EVENT Sunset on(7)", self.telldus_library,
                             self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNSET)
     self.assertTrue(event.minute == 0)
     self.assertTrue(
         event.weekday == [True, True, True, True, True, True, True])
     self.assertTrue(event.restriction == mas.TimeEvent.RESTRICTION_NONE)
     self.assertTrue(isinstance(event.function, mas.FunctionOn))
     self.assertTrue(event.function.devices == [7])
Exemple #16
0
 def test_parse_EVENT_on(self):
     event = mas.parse_EVENT("EVENT 00:01 Mon/Tue on(43)",
                             self.telldus_library, self.groups, False)
     self.assertTrue(event.hour == 0)
     self.assertTrue(event.minute == 1)
     self.assertTrue(
         event.weekday == [True, True, False, False, False, False, False])
     self.assertTrue(event.restriction == mas.TimeEvent.RESTRICTION_NONE)
     self.assertTrue(isinstance(event.function, mas.FunctionOn))
     self.assertTrue(event.function.devices == [43])
Exemple #17
0
 def test_parse_EVENT_lat_long_not_set(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sundown on(1)", self.telldus_library,
                         groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sunup on(1)", self.telldus_library,
                         groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT Sunrise on(1)", self.telldus_library,
                         groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT Sunset on(1)", self.telldus_library, groups,
                         False)
Exemple #18
0
 def test_sunset_offset_trig_over_day(self):
     event = mas.parse_EVENT("EVENT Sunset+3 on(1)", self.telldus_library,
                             self.groups, True)
     t_sunrise = datetime.time(1)
     t_sunset = datetime.time(22)
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 22, 00), t_sunrise,
                          t_sunset))
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 4, 1, 00), t_sunrise,
                          t_sunset))
Exemple #19
0
 def test_sunrise_offset_trig_plus(self):
     event = mas.parse_EVENT("EVENT Sunrise+3.5 on(1)",
                             self.telldus_library, self.groups, True)
     t_sunrise = datetime.time(10, 1)
     t_sunset = datetime.time(18)
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 10, 00), t_sunrise,
                          t_sunset))
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 13, 31), t_sunrise,
                          t_sunset))
Exemple #20
0
 def test_sunset_offset_trig_minus(self):
     event = mas.parse_EVENT("EVENT Sunset-0.2 on(1)", self.telldus_library,
                             self.groups, True)
     t_sunrise = datetime.time(10)
     t_sunset = datetime.time(18)
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 17, 48), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 18, 00), t_sunrise,
                          t_sunset))
Exemple #21
0
 def test_parse_EVENT_lat_long_not_set(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sundown on(1)",  
                 self.telldus_library, groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sunup on(1)",  
                 self.telldus_library, groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT Sunrise on(1)",  
                 self.telldus_library, groups, False)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT Sunset on(1)",  
                 self.telldus_library, groups, False)
Exemple #22
0
 def test_parse_EVENT_sunset(self):
     event = mas.parse_EVENT("EVENT Sunset on(7)",  
     self.telldus_library, self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNSET)
     self.assertTrue(event.minute == 0)
     self.assertTrue(event.weekday == 
     [True,True,True,True,True,True,True])
     self.assertTrue(event.restriction == 
     mas.TimeEvent.RESTRICTION_NONE)
     self.assertTrue(isinstance(event.function,
     mas.FunctionOn))
     self.assertTrue(event.function.devices == [7])
Exemple #23
0
 def test_parse_EVENT_on(self):
     event = mas.parse_EVENT("EVENT 00:01 Mon/Tue on(43)", 
     self.telldus_library, self.groups, False)
     self.assertTrue(event.hour == 0)
     self.assertTrue(event.minute == 1)
     self.assertTrue(event.weekday == 
     [True,True,False,False,False,False,False])
     self.assertTrue(event.restriction == 
     mas.TimeEvent.RESTRICTION_NONE)
     self.assertTrue(isinstance(event.function,
     mas.FunctionOn))
     self.assertTrue(event.function.devices == [43])
Exemple #24
0
 def test_restriction_sundown(self):
     event = mas.parse_EVENT("EVENT 13:00 Sundown on(1)",
                             self.telldus_library, self.groups, True)
     t = datetime.datetime(2014, 3, 3, 13, 0)
     t_sunrise = datetime.time(10)
     t_sunset = datetime.time(18)
     self.assertTrue(
         event.time_match(t, datetime.time(10), datetime.time(12, 59)))
     self.assertFalse(
         event.time_match(t, datetime.time(10), datetime.time(13, 1)))
     self.assertFalse(
         event.time_match(t, datetime.time(12, 59), datetime.time(18, 0)))
     self.assertTrue(
         event.time_match(t, datetime.time(13, 1), datetime.time(18, 0)))
Exemple #25
0
 def test_restriction_sundown(self):
     event = mas.parse_EVENT("EVENT 13:00 Sundown on(1)", 
     self.telldus_library, self.groups, True) 
     t = datetime.datetime(2014,3,3,13,0)
     t_sunrise = datetime.time(10) 
     t_sunset = datetime.time(18) 
     self.assertTrue(event.time_match(t,datetime.time(10),
                                         datetime.time(12,59)))
     self.assertFalse(event.time_match(t, datetime.time(10),
                                         datetime.time(13,1)))
     self.assertFalse(event.time_match(t, datetime.time(12,59),
                                         datetime.time(18,0)))  
     self.assertTrue(event.time_match(t, datetime.time(13,1),
                                         datetime.time(18,0)))                                             
Exemple #26
0
 def test_sunset_trig(self):
     event = mas.parse_EVENT("EVENT Sunset on(1)", 
     self.telldus_library, self.groups, True) 
     t_sunrise = datetime.time(10) 
     t_sunset = datetime.time(18) 
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,7,12),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,17,59),
                     t_sunrise,t_sunset))
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,18,00),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,18,1),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,3,23,59),
                     t_sunrise,t_sunset))
Exemple #27
0
 def test_parse_EVENT_wrong_time(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 1344 Sunup off(1)", 
         self.telldus_library, self.groups)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 25:23 Sunup off(1)", 
         self.telldus_library, self.groups)			
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 23:61 Sunup off(1)", 
         self.telldus_library, self.groups)
Exemple #28
0
 def test_parse_EVENT_wrong_time(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 1344 Sunup off(1)", self.telldus_library,
                         self.groups)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 25:23 Sunup off(1)", self.telldus_library,
                         self.groups)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 23:61 Sunup off(1)", self.telldus_library,
                         self.groups)
Exemple #29
0
 def test_sunset_trig(self):
     event = mas.parse_EVENT("EVENT Sunset on(1)", self.telldus_library,
                             self.groups, True)
     t_sunrise = datetime.time(10)
     t_sunset = datetime.time(18)
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 7, 12), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 17, 59), t_sunrise,
                          t_sunset))
     self.assertTrue(
         event.time_match(datetime.datetime(2014, 3, 3, 18, 00), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 18, 1), t_sunrise,
                          t_sunset))
     self.assertFalse(
         event.time_match(datetime.datetime(2014, 3, 3, 23, 59), t_sunrise,
                          t_sunset))
Exemple #30
0
 def test_weekday2(self):
     event = mas.parse_EVENT("EVENT 10:00 Mon/Sun on(1)", 
     self.telldus_library, self.groups, False) 
     t_sunrise = datetime.time(10) 
     t_sunset = datetime.time(18) 
     # 2014-03-03 is a Monday
     self.assertTrue(event.time_match(datetime.datetime(2014,3,3,10,0),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,4,10,0),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,5,10,0),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,6,10,0),
                     t_sunrise,t_sunset)) 
     self.assertFalse(event.time_match(datetime.datetime(2014,3,7,10,0),
                     t_sunrise,t_sunset))
     self.assertFalse(event.time_match(datetime.datetime(2014,3,8,10,0),
                     t_sunrise,t_sunset)) 
     self.assertTrue(event.time_match(datetime.datetime(2014,3,9,10,0),
                     t_sunrise,t_sunset))   
Exemple #31
0
 def test_parse_EVENT_too_short(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23", self.telldus_library, self.groups)
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT", self.telldus_library, self.groups)
Exemple #32
0
 def test_parse_EVENT_sunrise_offset_minus0p5(self):
     event = mas.parse_EVENT("EVENT Sunrise-0.5 off(4)",  
     self.telldus_library, self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNRISE)
     self.assertTrue(event.minute == -30)        
Exemple #33
0
 def test_parse_EVENT_sunset_offset_plus4p1(self):
     event = mas.parse_EVENT("EVENT Sunset+4.1 off(4)",  
     self.telldus_library, self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNSET)
     self.assertTrue(event.minute == 246)    
Exemple #34
0
 def test_parse_EVENT_group_pass(self):
     groups = mas.Groups()
     groups.add(mas.parse_GROUP('GROUP 3 "My name" 2 4 6'))
     event = mas.parse_EVENT("EVENT 01:23 Sundown on(G3)",  
     self.telldus_library, groups)
     self.assertTrue(event.function.devices == [2,4,6])
Exemple #35
0
 def test_parse_EVENT_group_does_not_exist(self):
     groups = mas.Groups()
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sundown on(G2)",  
     self.telldus_library, groups)
Exemple #36
0
 def test_parse_EVENT_too_long(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sunup illegal off(1)", 
         self.telldus_library, self.groups)	
Exemple #37
0
 def test_parse_EVENT_too_long(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sunup illegal off(1)",
                         self.telldus_library, self.groups)
Exemple #38
0
 def test_parse_EVENT_dim(self):
     event = mas.parse_EVENT("EVENT 01:23 Sundown dim(5,50)",
                             self.telldus_library, self.groups)
     self.assertTrue(isinstance(event.function, mas.FunctionDim))
     self.assertTrue(event.function.devices == [5])
     self.assertTrue(event.function.dim_level == 50)
Exemple #39
0
 def test_parse_EVENT_group_does_not_exist(self):
     groups = mas.Groups()
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 01:23 Sundown on(G2)", self.telldus_library,
                         groups)
Exemple #40
0
 def test_parse_EVENT_sunrise_offset_minus0p5(self):
     event = mas.parse_EVENT("EVENT Sunrise-0.5 off(4)",
                             self.telldus_library, self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNRISE)
     self.assertTrue(event.minute == -30)
Exemple #41
0
 def test_parse_EVENT_group_pass(self):
     groups = mas.Groups()
     groups.add(mas.parse_GROUP('GROUP 3 "My name" 2 4 6'))
     event = mas.parse_EVENT("EVENT 01:23 Sundown on(G3)",
                             self.telldus_library, groups)
     self.assertTrue(event.function.devices == [2, 4, 6])
Exemple #42
0
 def test_parse_EVENT_sunset_offset_plus4p1(self):
     event = mas.parse_EVENT("EVENT Sunset+4.1 off(4)",
                             self.telldus_library, self.groups)
     self.assertTrue(event.hour == mas.TimeEvent.TIME_SUNSET)
     self.assertTrue(event.minute == 246)
Exemple #43
0
 def test_parse_EVENT_function(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 12:10 Sunup dummy(1)", self.telldus_library,
                         self.groups)
Exemple #44
0
 def test_parse_EVENT_function(self):
     with self.assertRaises(Exception):
         mas.parse_EVENT("EVENT 12:10 Sunup dummy(1)", 
         self.telldus_library, self.groups)