diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2022-01-12 19:03:07 +0000 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2022-01-12 19:19:39 +0000 |
commit | 2351d658449e94c409c2a71ade714a6ca19d793a (patch) | |
tree | cd646ece048df9c4049f677f755e18b504dc6ae3 /deluge/tests | |
parent | e50927f5759bc4752baf231ad464f34852587822 (diff) | |
download | deluge-2351d658449e94c409c2a71ade714a6ca19d793a.tar.gz deluge-2351d658449e94c409c2a71ade714a6ca19d793a.tar.bz2 deluge-2351d658449e94c409c2a71ade714a6ca19d793a.zip |
[Plugins] Fix and refactor get_plugin_info method
A new metadata version 2.1 has optional Description that is causing an
TypeError when looking up the key in plugin_info since clients are
assuming values are always strings but the default is None.
Fixed TypeError by ensuring that the info dict has a default empty
string set for all keys.
Separated the parsing of the pkg_info into static method to make it
easier to test.
Changed the missing plugin info to only set the Name and Version as
'not available' since all other fields are optional.
Ref: https://dev.deluge-torrent.org/ticket/3476
Ref: https://packaging.python.org/en/latest/specifications/core-metadata/#description
Diffstat (limited to 'deluge/tests')
-rw-r--r-- | deluge/tests/test_plugin_metadata.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/deluge/tests/test_plugin_metadata.py b/deluge/tests/test_plugin_metadata.py index 341839e22..d86b245d8 100644 --- a/deluge/tests/test_plugin_metadata.py +++ b/deluge/tests/test_plugin_metadata.py @@ -20,9 +20,10 @@ class PluginManagerBaseTestCase(BaseTestCase): pm = PluginManagerBase('core.conf', 'deluge.plugin.core') for p in pm.get_available_plugins(): for key, value in pm.get_plugin_info(p).items(): - self.assertTrue(isinstance(f'{key}: {value}', ''.__class__)) + self.assertTrue(isinstance(f'{key}: {value}', str)) def test_get_plugin_info_invalid_name(self): pm = PluginManagerBase('core.conf', 'deluge.plugin.core') for key, value in pm.get_plugin_info('random').items(): - self.assertEqual(value, 'not available') + result = 'not available' if key in ('Name', 'Version') else '' + self.assertEqual(value, result) |