-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_profile.py
More file actions
217 lines (183 loc) · 7.45 KB
/
test_profile.py
File metadata and controls
217 lines (183 loc) · 7.45 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
"""
Test the MythTV Profile class
These tests should run against any recent production MythTV installation (>= 0.27).
Many of the tests simply check that the attribute exists. It would be nice
if regex's could be added that made sure the format of the response is correct.
All contributions welcome. :-)
"""
import re
import unittest
# from os.path import isdir, join, split, abspath
# from subprocess import Popen
# from tempfile import TemporaryFile
from mythtvlib.query import MythTVQuerySet
BRANCH_REs = ('fixes/0\.[0-9]{2}',)
class TestMythTVProfile(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)
self.mythtv_profile = MythTVQuerySet("Profile").all()[0]
return
def check_for_keys(self, feature_dict, key_list, msg):
"""Check that feature_dict contains all the keys in key_list"""
keys = list(feature_dict.keys())
for key in key_list:
self.assertIn(key, keys, msg)
return
def test_audio(self):
"""Ensure the audio feature has the expected keys"""
audio = self.mythtv_profile.audio
self.check_for_keys(audio, ['passthru', 'stereopcm', 'upmixtype',
'volcontrol', 'defaultupmix', 'maxchannels', 'passthruoverride',
'mixercontrol', 'audio_sys_version', 'sr_override', 'pulse',
'passthrudevice', 'jack', 'device', 'audio_sys', 'mixerdevice'],
"Profile.audio")
return
def test_branch(self):
"""Ensure the branch name looks reasonable."""
branch = self.mythtv_profile.branch
regexs = [re.compile(x) for x in BRANCH_REs]
have_match = False
for regex in regexs:
if regex.search(branch) is not None:
have_match = True
break
self.assertTrue(have_match,
"Unrecognised branch name: {0}".format(branch))
return
def test_channel_count(self):
"Ensure channel_count is returned as a positive number"
count = self.mythtv_profile.channel_count
self.assertGreaterEqual(count, 0, "Profile.channel_count")
return
def test_country(self):
"Ensure the country is a 2 letter string"
country = self.mythtv_profile.country
self.assertEqual(len(country), 2, "Profile.country length")
return
def test_database(self):
"Ensure the database has the expected keys"
db = self.mythtv_profile.database
self.check_for_keys(db, ['version', 'usedengine', 'engines', 'schema'],
"Profile.database")
return
def test_grabbers(self):
"Ensure grabbers are returned without error"
self.mythtv_profile.grabbers
return
def test_historical(self):
"Ensure historical has the expected keys"
historical = self.mythtv_profile.historical
self.check_for_keys(historical, ['showcount', 'rectime', 'db_age', 'reccount'],
"Profile.historical")
return
def test_language(self):
"Ensure the language is returned without error"
self.mythtv_profile.language
return
def test_libapi(self):
"Ensure the libapi version looks reasonable"
libapi = self.mythtv_profile.libapi
regex = re.compile(r'0\.[0-9]{2}\.[0-9]{8}-[0-9]{1,2}')
self.assertIsNotNone(regex.search(libapi),
"Profile.libapi")
return
def test_logurgency(self):
"Ensure the logurgenacy is a dictionary"
logurgency = self.mythtv_profile.logurgency
self.assertEqual(type(logurgency), dict,
"Profile.logurgency")
return
def test_mythtype(self):
"Ensure the mythtype is returned without error"
self.mythtv_profile.mythtype
return
def test_playbackprofile(self):
"Ensure the playbackprofile has the expected keys"
playbackprofile = self.mythtv_profile.playbackprofile
self.check_for_keys(playbackprofile, ['name', 'profiles'],
"Profile.playbackprofile")
return
def test_protocol(self):
"Ensure the protocol is returned with a reasonable value"
protocol = self.mythtv_profile.protocol
self.assertGreaterEqual(protocol, 77,
"Profile.protocol")
return
def test_qtversion(self):
"Ensure the qtversion looks reasonable"
qtversion = self.mythtv_profile.qtversion
regex = re.compile(r'[0-9]\.[0-9]{1,2}\.[0-9]{1,2}')
self.assertIsNotNone(regex.match(qtversion), "Profile.qtversion")
return
def test_recordings(self):
"Ensure recordings have the expected keys"
recordings = self.mythtv_profile.recordings
self.check_for_keys(recordings, ['scheduled', 'livetv', 'expireable',
'upcoming'],
"Profile.recordings")
return
def test_remote(self):
"Ensure remote returns without error"
self.mythtv_profile.remote
return
def test_scheduler(self):
"Ensure scheduler is a dictionary"
scheduler = self.mythtv_profile.scheduler
self.assertEqual(type(scheduler), dict,
"Profile.scheduler")
return
def test_sourcecount(self):
"Ensure sourcecount looks reasonable"
sourcecount = self.mythtv_profile.sourcecount
self.assertGreater(sourcecount, 0,
"Profile.sourcecount")
return
def test_storage(self):
"Ensure storage has the expected keys"
storage = self.mythtv_profile.storage
self.check_for_keys(storage, ['rectotal', 'videofree', 'recfree',
'videototal'],
"Profile.storage")
return
def test_theme(self):
"Ensure the theme is returned without error"
self.mythtv_profile.theme
return
def test_timezone(self):
"Ensure the timezone is returned without error"
self.mythtv_profile.timezone
return
def test_tuners(self):
"Ensure tuners is a dictionary"
tuners = self.mythtv_profile.tuners
self.assertEqual(type(tuners), dict,
"Profile.tuners")
return
def test_tzoffset(self):
"Ensure the tzoffset looks reasonable"
tzoffset = self.mythtv_profile.tzoffset
max_offset = 13*60*60
self.assertGreaterEqual(tzoffset, 0-max_offset,
"Profile.tzoffset minimum")
self.assertLessEqual(tzoffset, max_offset,
"Profile.tzoffset maximum")
return
def test_uuid(self):
"Ensure the uuid is returned without error"
self.mythtv_profile.uuid
return
def test_version(self):
"Ensure the version looks reasonable"
version = self.mythtv_profile.version
regex = re.compile(r'v0\.[0-9]{2}-[0-9]{1,5}-[a-z0-9]{8}')
self.assertIsNotNone(regex.match(version),
"Profile.version")
return
def test_vtpertuner(self):
"Ensure the vtpertuner looks reasonable"
vtpertuner = self.mythtv_profile.vtpertuner
self.assertGreaterEqual(vtpertuner, 1.0,
"Profile.vtpertuner minimum")
self.assertLessEqual(vtpertuner, 10.0,
"Profile.vtpertuner maximum")
return