Skip to content

Commit 2bf42eb

Browse files
authored
More coverage improvements (#137)
More experiments with coverage.
1 parent ff28f54 commit 2bf42eb

File tree

8 files changed

+103
-37
lines changed

8 files changed

+103
-37
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[report]
2+
omit = test/
3+
14
[run]
25
branch = true
36
omit = test/

lib/inputstreamhelper.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,31 @@ def _cmd_exists(cmd):
226226
# https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
227227
return subprocess.call('type ' + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
228228

229-
@staticmethod
230-
def _helper_disabled():
229+
def _helper_disabled(self):
231230
"""Return if inputstreamhelper has been disabled in settings.xml."""
232231
disabled = ADDON.getSetting('disabled')
233-
if not disabled:
234-
ADDON.setSetting('disabled', 'false') # create default entry
235-
disabled = 'false'
232+
if disabled is None:
233+
self.disable() # Create default entry
234+
disabled = 'true'
236235

237236
if disabled == 'true':
238237
log('inputstreamhelper is disabled in settings.xml.')
239238
return True
240239

241-
log('inputstreamhelper is enabled. You can disable inputstreamhelper by setting \"disabled\" to \"true\" in settings.xml \
242-
(Note: only recommended for developers knowing what they\'re doing!)')
243240
return False
244241

242+
@staticmethod
243+
def disable():
244+
''' Disable plugin '''
245+
if ADDON.getSetting('disabled') == 'false':
246+
ADDON.setSetting('disabled', 'true')
247+
248+
@staticmethod
249+
def enable():
250+
''' Enable plugin '''
251+
if ADDON.getSetting('disabled') == 'true':
252+
ADDON.setSetting('disabled', 'false')
253+
245254
def _inputstream_version(self):
246255
''' Return the requested inputstream version '''
247256
addon = xbmcaddon.Addon(self.inputstream_addon)

pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ disable=
77
redundant-keyword-arg,
88
too-many-branches,
99
too-many-instance-attributes,
10+
too-many-lines,
1011
too-many-return-statements,

test/test_ishelper_android_arm.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55
import unittest
6+
import platform
67
import inputstreamhelper
78

89
xbmc = __import__('xbmc')
@@ -15,24 +16,33 @@ class AndroidARMTests(unittest.TestCase):
1516

1617
def test_check_inputstream_mpd(self):
1718
inputstreamhelper.system_os = lambda: 'Android'
19+
platform.machine = lambda: 'arm'
1820
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
19-
is_helper._arch = lambda: 'arm'
2021
is_helper.remove_widevine()
2122
is_installed = is_helper.check_inputstream()
2223
self.assertTrue(is_installed, True)
2324

24-
def test_check_inputstream_mpd_again(self):
25+
def test_check_inputstream_hls_again(self):
2526
inputstreamhelper.system_os = lambda: 'Android'
26-
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
27-
is_helper._arch = lambda: 'arm'
27+
platform.machine = lambda: 'armv7'
28+
is_helper = inputstreamhelper.Helper('hls', drm='com.widevine.alpha')
2829
is_installed = is_helper.check_inputstream()
2930
self.assertTrue(is_installed, True)
3031

3132
def test_check_inputstream_rtmp(self):
3233
inputstreamhelper.system_os = lambda: 'Android'
33-
is_helper = inputstreamhelper.Helper('rtmp', drm='com.widevine.alpha')
34-
is_helper._arch = lambda: 'arm'
34+
platform.machine = lambda: 'armv8'
35+
is_helper = inputstreamhelper.Helper('rtmp')
36+
is_installed = is_helper.check_inputstream()
37+
self.assertTrue(is_installed, True)
38+
39+
def test_check_inputstream_disabled(self):
40+
inputstreamhelper.system_os = lambda: 'Android'
41+
platform.machine = lambda: 'arm'
42+
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
43+
is_helper.disable()
3544
is_installed = is_helper.check_inputstream()
45+
is_helper.enable()
3646
self.assertTrue(is_installed, True)
3747

3848

test/test_ishelper_linux_arm.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55
import unittest
6+
import platform
67
import inputstreamhelper
78

89
xbmc = __import__('xbmc')
@@ -15,24 +16,33 @@ class LinuxARMTests(unittest.TestCase):
1516

1617
def test_check_inputstream_mpd(self):
1718
inputstreamhelper.system_os = lambda: 'Linux'
19+
platform.machine = lambda: 'arm'
1820
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
19-
is_helper._arch = lambda: 'arm'
2021
is_helper.remove_widevine()
2122
is_installed = is_helper.check_inputstream()
2223
self.assertTrue(is_installed, True)
2324

24-
def test_check_inputstream_mpd_again(self):
25+
def test_check_inputstream_hls_again(self):
2526
inputstreamhelper.system_os = lambda: 'Linux'
26-
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
27-
is_helper._arch = lambda: 'arm'
27+
platform.machine = lambda: 'armv7'
28+
is_helper = inputstreamhelper.Helper('hls', drm='com.widevine.alpha')
2829
is_installed = is_helper.check_inputstream()
2930
self.assertTrue(is_installed, True)
3031

3132
def test_check_inputstream_rtmp(self):
3233
inputstreamhelper.system_os = lambda: 'Linux'
33-
is_helper = inputstreamhelper.Helper('rtmp', drm='com.widevine.alpha')
34-
is_helper._arch = lambda: 'arm'
34+
platform.machine = lambda: 'armv8'
35+
is_helper = inputstreamhelper.Helper('rtmp')
36+
is_installed = is_helper.check_inputstream()
37+
self.assertTrue(is_installed, True)
38+
39+
def test_check_inputstream_disabled(self):
40+
inputstreamhelper.system_os = lambda: 'Linux'
41+
platform.machine = lambda: 'arm'
42+
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
43+
is_helper.disable()
3544
is_installed = is_helper.check_inputstream()
45+
is_helper.enable()
3646
self.assertTrue(is_installed, True)
3747

3848

test/test_ishelper_linux_x64.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55
import unittest
6+
import platform
67
import inputstreamhelper
78

89
xbmc = __import__('xbmc')
@@ -15,24 +16,34 @@ class LinuxX64Tests(unittest.TestCase):
1516

1617
def test_check_inputstream_mpd(self):
1718
inputstreamhelper.system_os = lambda: 'Linux'
19+
platform.machine = lambda: 'x86_64'
1820
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
19-
is_helper._arch = lambda: 'x86_64'
2021
is_helper.remove_widevine()
2122
is_installed = is_helper.check_inputstream()
2223
self.assertTrue(is_installed, True)
2324

24-
def test_check_inputstream_mpd_again(self):
25+
def test_check_inputstream_hls_again(self):
2526
inputstreamhelper.system_os = lambda: 'Linux'
26-
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
27-
is_helper._arch = lambda: 'x86_64'
27+
platform.machine = lambda: 'AMD64'
28+
platform.architecture = lambda: ['64bit', '']
29+
is_helper = inputstreamhelper.Helper('hls', drm='com.widevine.alpha')
2830
is_installed = is_helper.check_inputstream()
2931
self.assertTrue(is_installed, True)
3032

3133
def test_check_inputstream_rtmp(self):
3234
inputstreamhelper.system_os = lambda: 'Linux'
33-
is_helper = inputstreamhelper.Helper('rtmp', drm='com.widevine.alpha')
34-
is_helper._arch = lambda: 'x86_64'
35+
platform.machine = lambda: 'x86_64'
36+
is_helper = inputstreamhelper.Helper('rtmp')
37+
is_installed = is_helper.check_inputstream()
38+
self.assertTrue(is_installed, True)
39+
40+
def test_check_inputstream_disabled(self):
41+
inputstreamhelper.system_os = lambda: 'Linux'
42+
platform.machine = lambda: 'x86_64'
43+
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
44+
is_helper.disable()
3545
is_installed = is_helper.check_inputstream()
46+
is_helper.enable()
3647
self.assertTrue(is_installed, True)
3748

3849

test/test_ishelper_macos_x64.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55
import unittest
6+
import platform
67
import inputstreamhelper
78

89
xbmc = __import__('xbmc')
@@ -15,24 +16,34 @@ class DarwinX64Tests(unittest.TestCase):
1516

1617
def test_check_inputstream_mpd(self):
1718
inputstreamhelper.system_os = lambda: 'Darwin'
19+
platform.machine = lambda: 'x86_64'
1820
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
19-
is_helper._arch = lambda: 'x86_64'
2021
is_helper.remove_widevine()
2122
is_installed = is_helper.check_inputstream()
2223
self.assertTrue(is_installed, True)
2324

24-
def test_check_inputstream_mpd_again(self):
25+
def test_check_inputstream_hls_again(self):
2526
inputstreamhelper.system_os = lambda: 'Darwin'
26-
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
27-
is_helper._arch = lambda: 'x86_64'
27+
platform.machine = lambda: 'AMD64'
28+
platform.architecture = lambda: ['64bit', '']
29+
is_helper = inputstreamhelper.Helper('hls', drm='com.widevine.alpha')
2830
is_installed = is_helper.check_inputstream()
2931
self.assertTrue(is_installed, True)
3032

3133
def test_check_inputstream_rtmp(self):
3234
inputstreamhelper.system_os = lambda: 'Darwin'
33-
is_helper = inputstreamhelper.Helper('rtmp', drm='com.widevine.alpha')
34-
is_helper._arch = lambda: 'x86_64'
35+
platform.machine = lambda: 'x86_64'
36+
is_helper = inputstreamhelper.Helper('rtmp')
37+
is_installed = is_helper.check_inputstream()
38+
self.assertTrue(is_installed, True)
39+
40+
def test_check_inputstream_disabled(self):
41+
inputstreamhelper.system_os = lambda: 'Darwin'
42+
platform.machine = lambda: 'x86_64'
43+
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
44+
is_helper.disable()
3545
is_installed = is_helper.check_inputstream()
46+
is_helper.enable()
3647
self.assertTrue(is_installed, True)
3748

3849

test/test_ishelper_windows_x64.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55
import unittest
6+
import platform
67
import inputstreamhelper
78

89
xbmc = __import__('xbmc')
@@ -15,24 +16,34 @@ class WindowsX64Tests(unittest.TestCase):
1516

1617
def test_check_inputstream_mpd(self):
1718
inputstreamhelper.system_os = lambda: 'Windows'
19+
platform.machine = lambda: 'x86_64'
1820
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
19-
is_helper._arch = lambda: 'x86_64'
2021
is_helper.remove_widevine()
2122
is_installed = is_helper.check_inputstream()
2223
self.assertTrue(is_installed, True)
2324

24-
def test_check_inputstream_mpd_again(self):
25+
def test_check_inputstream_hls_again(self):
2526
inputstreamhelper.system_os = lambda: 'Windows'
26-
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
27-
is_helper._arch = lambda: 'x86_64'
27+
platform.machine = lambda: 'AMD64'
28+
platform.architecture = lambda: ['64bit', '']
29+
is_helper = inputstreamhelper.Helper('hls', drm='com.widevine.alpha')
2830
is_installed = is_helper.check_inputstream()
2931
self.assertTrue(is_installed, True)
3032

3133
def test_check_inputstream_rtmp(self):
3234
inputstreamhelper.system_os = lambda: 'Windows'
33-
is_helper = inputstreamhelper.Helper('rtmp', drm='com.widevine.alpha')
34-
is_helper._arch = lambda: 'x86_64'
35+
platform.machine = lambda: 'x86_64'
36+
is_helper = inputstreamhelper.Helper('rtmp')
37+
is_installed = is_helper.check_inputstream()
38+
self.assertTrue(is_installed, True)
39+
40+
def test_check_inputstream_disabled(self):
41+
inputstreamhelper.system_os = lambda: 'Windows'
42+
platform.machine = lambda: 'x86_64'
43+
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
44+
is_helper.disable()
3545
is_installed = is_helper.check_inputstream()
46+
is_helper.enable()
3647
self.assertTrue(is_installed, True)
3748

3849

0 commit comments

Comments
 (0)