|
| 1 | +# This Python file uses the following encoding: utf-8 |
| 2 | + |
| 3 | +class FakeAddon(object): |
| 4 | + def __init__(self, id='test.addon'): |
| 5 | + self.id = id |
| 6 | + self.name = 'Test Add-on' |
| 7 | + self.version = '0.0.1' |
| 8 | + |
| 9 | + def getSetting(self, id): |
| 10 | + return '' |
| 11 | + |
| 12 | + def setSetting(self, id, value): |
| 13 | + pass |
| 14 | + |
| 15 | + def openSettings(self): |
| 16 | + pass |
| 17 | + |
| 18 | + def getAddonInfo(self, key): |
| 19 | + return getattr(self, key) |
| 20 | + |
| 21 | + |
| 22 | +class FakeCode(object): |
| 23 | + def __init__(self, co_filename, co_name): |
| 24 | + self.co_filename = co_filename |
| 25 | + self.co_name = co_name |
| 26 | + |
| 27 | +# fakes for tracebacks |
| 28 | +# https://stackoverflow.com/questions/19248784/faking-a-traceback-in-python |
| 29 | +class FakeFrame(object): |
| 30 | + def __init__(self, f_code, f_globals): |
| 31 | + self.f_code = f_code |
| 32 | + self.f_globals = f_globals |
| 33 | + |
| 34 | + |
| 35 | +class FakeTraceback(object): |
| 36 | + def __init__(self, frames, line_nums): |
| 37 | + if len(frames) != len(line_nums): |
| 38 | + raise ValueError("Ya messed up!") |
| 39 | + self._frames = frames |
| 40 | + self._line_nums = line_nums |
| 41 | + self.tb_frame = frames[0] |
| 42 | + self.tb_lineno = line_nums[0] |
| 43 | + |
| 44 | + @property |
| 45 | + def tb_next(self): |
| 46 | + if len(self._frames) > 1: |
| 47 | + return FakeTraceback(self._frames[1:], self._line_nums[1:]) |
| 48 | + |
| 49 | + |
| 50 | +class FakeException(Exception): |
| 51 | + def __init__(self, *args, **kwargs): |
| 52 | + self._tb = None |
| 53 | + super(Exception, self).__init__(*args, **kwargs) |
| 54 | + |
| 55 | + @property |
| 56 | + def __traceback__(self): |
| 57 | + return self._tb |
| 58 | + |
| 59 | + @__traceback__.setter |
| 60 | + def __traceback__(self, value): |
| 61 | + self._tb = value |
| 62 | + |
| 63 | + def with_traceback(self, value): |
| 64 | + self._tb = value |
| 65 | + return self |
| 66 | + |
| 67 | +code1 = FakeCode("made_up_filename.py", "non_existent_function") |
| 68 | +code2 = FakeCode("another_non_existent_file.py", "another_non_existent_method") |
| 69 | +frame1 = FakeFrame(code1, {}) |
| 70 | +frame2 = FakeFrame(code2, {}) |
| 71 | +EXC_VALUE = FakeException('Another AFL 503 error') |
| 72 | +TB = FakeTraceback([frame1, frame2], [1,3]) |
| 73 | +EXC_FORMATTED_SUMMARY = "made_up_filename.py (1) - FakeException: " \ |
| 74 | + "Another AFL 503 error" |
| 75 | +EXC_VALUE_FORMATTED = 'FakeException: Another AFL 503 error' |
| 76 | + |
| 77 | + |
| 78 | +PLUGIN_URL_DICT = { |
| 79 | + 'category': 'channel/abc1', |
| 80 | + 'episode_count': '18', |
| 81 | + 'series_url': 'programs/7-30/NC1901H086S00' |
| 82 | +} |
| 83 | + |
| 84 | +PLUGIN_URL_STRING = "?category=channel%2Fabc1&episode_count=18&series_url" \ |
| 85 | + "=programs%2F7-30%2FNC1901H086S00" |
| 86 | + |
| 87 | +UNICODE_STRING_WITH_ACCENTS = u"Klüft skräms inför på fédéral électoral große" |
| 88 | + |
| 89 | + |
| 90 | +EXC_INFO = (TypeError, ) |
| 91 | + |
| 92 | +BUILD_VERSION = '18.2 Git:20190422-f2643566d0' |
| 93 | + |
| 94 | +ISSUE_URL = 'https://github.com/aussieaddons/issue-reports/issues/123' |
| 95 | + |
| 96 | +VALID_CONNECTION_INFO = [ |
| 97 | + { |
| 98 | + u'loc': u'-35.3066,149.1250', u'city': u'Capital Hill', |
| 99 | + u'ip': u'123.234.56.78', |
| 100 | + u'region': u'Australian Capital Territory', |
| 101 | + u'hostname': u'123-234-56-78.dyn.iinet.net.au', |
| 102 | + u'country': u'AU', |
| 103 | + u'org': u'AS4739 Internode Pty Ltd', u'postal': u'2600' |
| 104 | + } |
| 105 | +] |
| 106 | + |
| 107 | +INVALID_CONNECTION_INFO = [ |
| 108 | + { |
| 109 | + u'loc': u'42.0707,-72.0440', u'city': u'Southbridge', |
| 110 | + u'ip': u'66.87.125.72', |
| 111 | + u'region': u'Massachusetts', |
| 112 | + u'hostname': u'66-87-125-72.pools.spcsdns.net', |
| 113 | + u'country': u'US', |
| 114 | + u'org': u'AS10507 Sprint Personal Communications Systems', |
| 115 | + u'postal': u'01550' |
| 116 | + }, |
| 117 | + { |
| 118 | + u'loc': u'-33.9167,151.1830', u'city': u'Saint Peters', |
| 119 | + u'ip': u'137.59.252.166', |
| 120 | + u'region': u'New South Wales', |
| 121 | + u'hostname': u'137.59.252.166', |
| 122 | + u'country': u'AU', |
| 123 | + u'org': u'AS46562 Total Server Solutions L.L.C', u'postal': u'2015' |
| 124 | + }, |
| 125 | + { |
| 126 | + u'loc': u'37.3422,-121.8830', u'city': u'San Jose', |
| 127 | + u'ip': u'216.151.183.137', |
| 128 | + u'region': u'California', |
| 129 | + u'hostname': u'216-151-183-137.ipvanish.com', |
| 130 | + u'country': u'US', |
| 131 | + u'org': u'AS33438 Highwinds Network Group, Inc.', u'postal': u'95112' |
| 132 | + }, |
| 133 | + { |
| 134 | + u'loc': u'37.3422,-121.8830', u'city': u'Sydney', |
| 135 | + u'ip': u'209.107.195.97', |
| 136 | + u'region': u'New South Wales', |
| 137 | + u'hostname': u'209-107-195-97.ipvanish.com', |
| 138 | + u'country': u'AU', |
| 139 | + u'org': u'AS33438 Highwinds Network Group, Inc.', u'postal': u'2000' |
| 140 | + } |
| 141 | +] |
| 142 | + |
| 143 | +# Some systems we support |
| 144 | +SYSTEMS = [ |
| 145 | + # Linux |
| 146 | + { |
| 147 | + 'system': 'Linux', |
| 148 | + 'platforms': ['System.Platform.Linux'], |
| 149 | + 'machine': 'x86_64', |
| 150 | + 'expected_system': 'Linux', |
| 151 | + 'expected_arch': 'x64', |
| 152 | + }, |
| 153 | + # Generic Windows |
| 154 | + { |
| 155 | + 'system': 'Windows', |
| 156 | + 'platforms': ['System.Platform.Windows'], |
| 157 | + 'machine': 'AMD64', |
| 158 | + 'arch': '32bit', |
| 159 | + 'expected_system': 'Windows', |
| 160 | + 'expected_arch': 'x86', |
| 161 | + }, |
| 162 | + # Generic Mac OS X |
| 163 | + { |
| 164 | + 'system': 'Darwin', |
| 165 | + 'platforms': ['System.Platform.OSX'], |
| 166 | + 'machine': 'x86_64', |
| 167 | + 'expected_system': 'Darwin', |
| 168 | + 'expected_arch': 'x64', |
| 169 | + }, |
| 170 | + # Raspberry Pi |
| 171 | + { |
| 172 | + 'system': 'Linux', |
| 173 | + 'platforms': ['System.Platform.Linux.RaspberryPi', |
| 174 | + 'System.Platform.Linux'], |
| 175 | + 'machine': 'armv7l', |
| 176 | + 'expected_system': 'Linux', |
| 177 | + 'expected_arch': 'arm', |
| 178 | + }, |
| 179 | + # Nexus Player/MiBox |
| 180 | + { |
| 181 | + 'system': 'Linux', |
| 182 | + 'platforms': ['System.Platform.Android', |
| 183 | + 'System.Platform.Linux'], |
| 184 | + 'machine': 'arm', |
| 185 | + 'expected_system': 'Android', |
| 186 | + 'expected_arch': 'arm', |
| 187 | + }, |
| 188 | + # Windows (UWP) |
| 189 | + { |
| 190 | + 'system': 'Windows', |
| 191 | + 'platforms': ['System.Platform.Windows', |
| 192 | + 'System.Platform.UWP'], |
| 193 | + 'machine': '', |
| 194 | + 'arch': '64bit', |
| 195 | + 'expected_system': 'UWP', |
| 196 | + 'expected_arch': 'x64', |
| 197 | + }, |
| 198 | + # Xbox One |
| 199 | + { |
| 200 | + 'system': 'Windows', |
| 201 | + 'platforms': ['System.Platform.Windows', |
| 202 | + 'System.Platform.UWP'], |
| 203 | + 'machine': '', |
| 204 | + 'arch': '64bit', |
| 205 | + 'expected_system': 'UWP', |
| 206 | + 'expected_arch': 'x64', |
| 207 | + }, |
| 208 | +] |
| 209 | + |
| 210 | + |
| 211 | +ARCHES = [ |
| 212 | + ('aarch64', 'aarch64'), |
| 213 | + ('aarch64_be', 'aarch64'), |
| 214 | + ('arm64', 'aarch64'), |
| 215 | + ('arm', 'arm'), |
| 216 | + ('armv7l', 'arm'), |
| 217 | + ('armv8', 'aarch64'), |
| 218 | + ('AMD64', 'x64'), |
| 219 | + ('x86_64', 'x64'), |
| 220 | + ('x86', 'x86'), |
| 221 | + ('i386', 'x86'), |
| 222 | + ('i686', 'x86'), |
| 223 | +] |
| 224 | + |
| 225 | +KODI_BUILDS = [ |
| 226 | + { |
| 227 | + 'build': '13.2 Git:Unknown', |
| 228 | + 'version': '13.2', |
| 229 | + 'major_version': 13, |
| 230 | + 'build_name': 'Gotham', |
| 231 | + 'build_date': None, |
| 232 | + }, |
| 233 | + { |
| 234 | + 'build': '17.6 Git:20180213-nogitfound', |
| 235 | + 'version': '17.6', |
| 236 | + 'major_version': 17, |
| 237 | + 'build_name': 'Krypton', |
| 238 | + 'build_date': '20180213', |
| 239 | + }, |
| 240 | + { |
| 241 | + 'build': '17.6 Git:20171119-ced5097', |
| 242 | + 'version': '17.6', |
| 243 | + 'major_version': 17, |
| 244 | + 'build_name': 'Krypton', |
| 245 | + 'build_date': '20171119', |
| 246 | + }, |
| 247 | + { |
| 248 | + 'build': '18.0-ALPHA1 Git:20180225-02cb21ec7d', |
| 249 | + 'version': '18.0', |
| 250 | + 'major_version': 18, |
| 251 | + 'build_name': 'Leia', |
| 252 | + 'build_date': '20180225', |
| 253 | + }, |
| 254 | +] |
| 255 | + |
| 256 | + |
| 257 | +# Expected output from calling Addons.GetAddonDetails for IA if not installed |
| 258 | +IA_NOT_AVAILABLE = { |
| 259 | + 'id': 1, |
| 260 | + 'jsonrpc': '2.0', |
| 261 | + 'error': { |
| 262 | + 'message': 'Invalid params.', |
| 263 | + 'code': -32602 |
| 264 | + } |
| 265 | +} |
| 266 | + |
| 267 | +IA_ENABLED = { |
| 268 | + 'id': 1, |
| 269 | + 'jsonrpc': u'2.0', |
| 270 | + 'result': { |
| 271 | + 'addon': { |
| 272 | + 'addonid': 'inputstream.adaptive', |
| 273 | + 'enabled': True, |
| 274 | + 'type': 'kodi.inputstream' |
| 275 | + } |
| 276 | + } |
| 277 | +} |
| 278 | + |
| 279 | +TRANS_PATH_ARGS = [ |
| 280 | + "addon.getSetting('DECRYPTERPATH')", |
| 281 | + 'special://xbmcbinaddons/inputstream.adaptive', |
| 282 | + 'special://home/' |
| 283 | +] |
| 284 | + |
| 285 | +TRANSLATED_PATHS = { |
| 286 | + 'Linux': ['/storage/.kodi/cdm', |
| 287 | + '/storage/.kodi/addons/inputstream.adaptive'], |
| 288 | + 'Windows': ['C:/Users/user/AppData/Roaming/Kodi/cdm', |
| 289 | + 'C:/Program Files (x86)/Kodi/addons/inputstream.adaptive'], |
| 290 | + 'Darwin': ['/Users/User/Library/Application Support/Kodi/cdm/'] |
| 291 | +} |
0 commit comments