def test_check_required_plugins(self):
        with mock.patch.object(Plugin, '__init__') as mock_plugin:
            mock_plugin.return_value = None
            plugin_manager = PluginManager('')

            plugins = {}
            plugins_config = {
                'plugin_1': {},
                'plugin_2': {}
            }

            with self.assertRaises(PluginRequirementsError) as e:
                plugin_manager._check_required_plugins(plugins_config, plugins)

            self.assertEqual(
                str(e.exception),
                "Missing required plugins: 'plugin_1', 'plugin_2'"
            )

            plugin_1 = Plugin(plugin_manager, {})
            plugin_1.version = '0.0.1'

            plugin_2 = Plugin(plugin_manager, {})
            plugin_2.version = '2.0.1'

            plugins = {
                'plugin_1': plugin_1,
                'plugin_2': plugin_2
            }
            plugins_config = {
                'plugin_1': {
                    'version': '2.0.0'
                },
                'plugin_2': {}
            }

            with self.assertRaises(PluginRequirementsError) as e:
                plugin_manager._check_required_plugins(plugins_config, plugins)

            self.assertEqual(
                str(e.exception),
                "Plugin 'plugin_1' must at least version '2.0.0'"
            )

            plugins_config = {
                'plugin_1': {
                    'version': '0.0.1'
                },
                'plugin_2': {
                    'version': '1.0.0'
                }
            }

            result = plugin_manager._check_required_plugins(plugins_config, plugins)
            self.assertEquals(result, None)
Exemple #2
0
    def test_check_required_plugin_file_settings_success(self):
        check = Plugin.check_required_plugin_file_settings(
            self.valid_plugin_info,
            Plugin.required_fields
        )

        self.assertEquals(check, True)
Exemple #3
0
    def test_check_required_plugin_file_settings_error(self):
        with self.assertRaises(PluginJsonFileError) as e:
            Plugin.check_required_plugin_file_settings(self.invalid_plugin_info, Plugin.required_fields)

        self.assertEqual(str(e.exception), "Missing json attribute 'name'")