Skip to content
Permalink
Browse files
Add tests for experimental plugin dependencies
  • Loading branch information
gacarrillor authored and github-actions committed Nov 4, 2021
1 parent 0808127 commit 194a38bb24b9f230f353b6573e56a0d896f8dadd
Showing with 85 additions and 7 deletions.
  1. +84 −6 tests/src/python/test_plugindependencies.py
  2. +1 −1 tests/testdata/plugindependencies_data.json
@@ -71,32 +71,52 @@ def tearDown(self):

def test_find_dependencies(self):

to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'InaSAFE': None}, installed_plugins=self.installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'InaSAFE': None},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install, {})
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'InaSAFE': '110.1'}, installed_plugins=self.installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'InaSAFE': '110.1'},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install, {})
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found['InaSAFE']['version_installed'], '5.0.0')

# QuickWkt is installed, version is not specified: ignore
installed_plugins = self.installed_plugins
installed_plugins['QuickWKT'] = '2.1'
to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'QuickMapServices': '0.19.10.1', 'QuickWKT': None}, installed_plugins=self.installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'QuickMapServices': '0.19.10.1',
'QuickWKT': None},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['QuickMapServices']['version_required'], '0.19.10.1')
self.assertEqual(to_install['QuickMapServices']['version_available'], '0.19.10.1')
self.assertEqual(to_install['QuickMapServices']['use_stable_version'], True)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# QuickWkt is installed, version requires upgrade and it's in the repo: upgrade
to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'QuickWKT': '3.1'}, installed_plugins=installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'QuickWKT': '3.1'},
installed_plugins=installed_plugins)
self.assertEqual(to_install, {})
self.assertEqual(to_upgrade['QuickWKT']['version_required'], '3.1')
self.assertEqual(to_upgrade['QuickWKT']['version_available'], '3.1')
self.assertEqual(to_upgrade['QuickWKT']['use_stable_version'], True)
self.assertEqual(not_found, {})

# QuickWkt is installed, version requires upgrade and it's NOT in the repo: not found
to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'QuickWKT': '300.11234'}, installed_plugins=installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'QuickWKT': '300.11234'},
installed_plugins=installed_plugins)
self.assertEqual(to_install, {})
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found['QuickWKT']['version_required'], '300.11234')
@@ -105,11 +125,69 @@ def test_find_dependencies(self):

# Installed version is > than required: ignore (no downgrade is currently possible)
installed_plugins['QuickWKT'] = '300.1'
to_install, to_upgrade, not_found = find_dependencies('qgisce', self.plugin_data, plugin_deps={'QuickWKT': '1.2'}, installed_plugins=installed_plugins)
to_install, to_upgrade, not_found = find_dependencies('qgisce',
self.plugin_data,
plugin_deps={'QuickWKT': '1.2'},
installed_plugins=installed_plugins)
self.assertEqual(to_install, {})
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# A plugin offers both stable and experimental versions. A dependent plugin requires the experimental one.
to_install, to_upgrade, not_found = find_dependencies('LADM-COL-Add-on-Ambiente',
self.plugin_data,
plugin_deps={'Asistente LADM-COL': '3.2.0-beta-1'},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['Asistente LADM-COL']['version_required'], '3.2.0-beta-1')
self.assertEqual(to_install['Asistente LADM-COL']['version_available'], '3.2.0-beta-1')
self.assertEqual(to_install['Asistente LADM-COL']['use_stable_version'], False)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# A plugin offers both stable and experimental versions. A dependent plugin requires the stable one.
to_install, to_upgrade, not_found = find_dependencies('LADM-COL-Add-on-Ambiente',
self.plugin_data,
plugin_deps={'Asistente LADM-COL': '3.1.9'},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['Asistente LADM-COL']['version_required'], '3.1.9')
self.assertEqual(to_install['Asistente LADM-COL']['version_available'], '3.1.9')
self.assertEqual(to_install['Asistente LADM-COL']['use_stable_version'], True)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# A plugin offers both stable and experimental versions. If no version is required, choose the stable one.
to_install, to_upgrade, not_found = find_dependencies('LADM-COL-Add-on-Ambiente',
self.plugin_data,
plugin_deps={'Asistente LADM-COL': None},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['Asistente LADM-COL']['version_required'], None)
self.assertEqual(to_install['Asistente LADM-COL']['version_available'], '3.1.9')
self.assertEqual(to_install['Asistente LADM-COL']['use_stable_version'], True)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# A plugin only offers experimental version. If the experimental version is required, give it to him.
to_install, to_upgrade, not_found = find_dependencies('dependent-on-unique_values_viewer',
self.plugin_data,
plugin_deps={'UniqueValuesViewer': '0.2'},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['UniqueValuesViewer']['version_required'], '0.2')
self.assertEqual(to_install['UniqueValuesViewer']['version_available'], '0.2')
self.assertEqual(to_install['UniqueValuesViewer']['use_stable_version'], False)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})

# A plugin only offers experimental version. If no version is required, choose the experimental one.
to_install, to_upgrade, not_found = find_dependencies('dependent-on-unique_values_viewer',
self.plugin_data,
plugin_deps={'UniqueValuesViewer': None},
installed_plugins=self.installed_plugins)
self.assertEqual(to_install['UniqueValuesViewer']['version_required'], None)
self.assertEqual(to_install['UniqueValuesViewer']['version_available'], '0.2')
self.assertEqual(to_install['UniqueValuesViewer']['use_stable_version'], False)
self.assertEqual(to_upgrade, {})
self.assertEqual(not_found, {})


def pluginSuite():
return unittest.makeSuite(PluginDependenciesTest, 'test')

Large diffs are not rendered by default.

0 comments on commit 194a38b

Please sign in to comment.