mirror of
https://github.com/lutris/lutris
synced 2024-09-05 07:23:32 +00:00
Add test for handling noop when missing lib
Signed-off-by: Antoine Mazeas <antoine@karthanis.net>
This commit is contained in:
parent
778d7f310e
commit
bf7d7f91a1
|
@ -18,8 +18,8 @@ def _try_import_moddb_library():
|
|||
logger.warn('The moddb library is not available, though the installer is attempting to install a file hosted on moddb.com. The moddb.com URLs will not be transformed, and rather passed as-is.')
|
||||
|
||||
class ModDB:
|
||||
def __init__(self, parse_page_method: types.MethodType=None):
|
||||
self.moddb_lib = _try_import_moddb_library()
|
||||
def __init__(self, parse_page_method: types.MethodType=None, moddb_lib: types.ModuleType=_try_import_moddb_library()):
|
||||
self.moddb_lib = moddb_lib
|
||||
self.parse = parse_page_method
|
||||
if self.parse is None and self.moddb_lib is not None:
|
||||
self.parse = self.moddb_lib.parse_page
|
||||
|
|
|
@ -40,6 +40,13 @@ class ModDBHelperTests(unittest.TestCase):
|
|||
hlpr = ModDB(custom)
|
||||
self.assertEqual(hlpr.parse, custom)
|
||||
|
||||
## missing moddb lib handling
|
||||
def test_transform_url_missing_lib_noop(self):
|
||||
moddb_url = 'https://www.moddb.com/downloads/mirror/somethingsomething'
|
||||
hlpr = ModDB(moddb_lib=None)
|
||||
transformed = hlpr.transform_url(moddb_url)
|
||||
self.assertEqual(transformed, moddb_url)
|
||||
|
||||
## transform_url
|
||||
def test_transform_url_url_is_mirror_with_www_throws(self):
|
||||
moddb_url = 'https://www.moddb.com/downloads/mirror/somethingsomething'
|
||||
|
|
Loading…
Reference in a new issue