8 def test_timer(repeat = 0, timer_start = 3600, timer_length = 1000, sim_length = 86400 * 7):
10 import NavigationInstance
14 t = NavigationInstance.instance.RecordTimer
16 print "old mwt:", t.MaxWaitTime
17 t.MaxWaitTime = 86400 * 1000
20 NavigationInstance.instance.SleepTimer.MaxWaitTime = 86400 * 1000
22 t.processed_timers = [ ]
26 # generate a timer to test
27 import xml.etree.cElementTree
30 timer = RecordTimer.createTimer(xml.etree.cElementTree.fromstring(
35 serviceref="1:0:1:6DD2:44D:1:C00000:0:0:0:"
37 name="Test Event Name"
38 description="Test Event Description"
43 </timer>""" % (at + timer_start, at + timer_start + timer_length, repeat)
48 # run virtual environment
49 enigma.run(sim_length)
53 timers = t.processed_timers + t.timer_list
55 print "start: %s" % (time.ctime(at + 10))
57 assert len(timers) == 1
60 print "begin=%d, end=%d, repeated=%d, state=%d" % (t.begin - at, t.end - at, t.repeated, t.state)
61 print "begin: %s" % (time.ctime(t.begin))
62 print "end: %s" % (time.ctime(t.end))
64 # if repeat, check if the calculated repeated time of day matches the initial time of day
66 t_initial = time.localtime(at + timer_start)
67 t_repeated = time.localtime(timers[0].begin)
71 if t_initial[3:6] != t_repeated[3:6]:
72 raise tests.TestError("repeated timer time of day does not match")
74 import FakeNotifications
75 #sys.modules["Tools.Notifications"] = FakeNotifications
76 #sys.modules["Tools.NumericalTextInput.NumericalTextInput"] = FakeNotifications
78 # required stuff for timer (we try to keep this minimal)
80 enigma.init_record_config()
81 enigma.init_parental_control()
84 from events import log
90 # we are operating in CET/CEST
91 os.environ['TZ'] = 'CET'
94 #log(test_timer, test_name = "test_timer_repeating", base_time = calendar.timegm((2007, 3, 1, 12, 0, 0)), repeat=0x7f, sim_length = 86400 * 7)
95 log(test_timer, test_name = "test_timer_repeating_dst_skip", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 3600, repeat=0x7f, sim_length = 86400 * 7)
96 #log(test_timer, test_name = "test_timer_repeating_dst_start", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 10000, repeat=0x7f, sim_length = 86400 * 7)