-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathtest_timer.py
93 lines (65 loc) · 2.34 KB
/
test_timer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import enigma
import time
import tests
#enigma.reset()
def test_timer(repeat=0, timer_start=3600, timer_length=1000, sim_length=86400 * 7):
import NavigationInstance
at = time.time()
t = NavigationInstance.instance.RecordTimer
print(t)
print("old mwt:", t.MaxWaitTime)
t.MaxWaitTime = 86400 * 1000
# hack:
NavigationInstance.instance.SleepTimer.MaxWaitTime = 86400 * 1000
t.processed_timers = []
t.timer_list = []
# generate a timer to test
import xml.etree.ElementTree
import RecordTimer
timer = RecordTimer.createTimer(xml.etree.ElementTree.fromstring(
"""
<timer
begin="%d"
end="%d"
serviceref="1:0:1:6DD2:44D:1:C00000:0:0:0:"
repeated="%d"
name="Test Event Name"
description="Test Event Description"
afterevent="nothing"
eit="56422"
disabled="0"
justplay="0">
</timer>""" % (at + timer_start, at + timer_start + timer_length, repeat)
))
t.record(timer)
# run virtual environment
enigma.run(sim_length)
print("done.")
timers = t.processed_timers + t.timer_list
print("start: %s" % (time.ctime(at + 10)))
assert len(timers) == 1
for t in timers:
print("begin=%d, end=%d, repeated=%d, state=%d" % (t.begin - at, t.end - at, t.repeated, t.state))
print("begin: %s" % (time.ctime(t.begin)))
print("end: %s" % (time.ctime(t.end)))
# if repeat, check if the calculated repeated time of day matches the initial time of day
if repeat:
t_initial = time.localtime(at + timer_start)
t_repeated = time.localtime(timers[0].begin)
print(t_initial)
print(t_repeated)
if t_initial[3:6] != t_repeated[3:6]:
raise tests.TestError("repeated timer time of day does not match")
# required stuff for timer (we try to keep this minimal)
enigma.init_nav()
enigma.init_record_config()
enigma.init_parental_control()
from events import log
import calendar
import os
# we are operating in CET/CEST
os.environ['TZ'] = 'CET'
time.tzset()
#log(test_timer, test_name = "test_timer_repeating", base_time = calendar.timegm((2007, 3, 1, 12, 0, 0)), repeat=0x7f, sim_length = 86400 * 7)
log(test_timer, test_name="test_timer_repeating_dst_skip", base_time=calendar.timegm((2007, 3, 20, 0, 0, 0)), timer_start=3600, repeat=0x7f, sim_length=86400 * 7)
#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)