コード例 #1
0
    def get_plugin_by_name_exists_test(self):
        """
        Test running the get_plugin_by_name() method to find a plugin that exists
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.name = 'Mocked Plugin'
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]

        # WHEN: We run finalise_plugins()
        result = plugin_manager.get_plugin_by_name('Mocked Plugin')

        # THEN: The is_active() and finalise() methods should have been called
        self.assertEqual(result, mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin')
コード例 #2
0
    def test_get_plugin_by_name_exists(self):
        """
        Test running the get_plugin_by_name() method to find a plugin that exists
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.name = 'Mocked Plugin'
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]

        # WHEN: We run finalise_plugins()
        result = plugin_manager.get_plugin_by_name('Mocked Plugin')

        # THEN: The is_active() and finalise() methods should have been called
        assert result == mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin'
コード例 #3
0
    def get_plugin_by_name_does_not_exist_test(self):
        """
        Test running the get_plugin_by_name() method to find a plugin that does not exist
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.name = 'Mocked Plugin'
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]

        # WHEN: We run finalise_plugins()
        result = plugin_manager.get_plugin_by_name('Missing Plugin')

        # THEN: The is_active() and finalise() methods should have been called
        self.assertIsNone(result,
                          'The result for get_plugin_by_name should be None')
コード例 #4
0
ファイル: test_pluginmanager.py プロジェクト: ipic/projecao
    def test_get_plugin_by_name_exists(self):
        """
        Test running the get_plugin_by_name() method to find a plugin that exists
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.name = 'Mocked Plugin'
        plugin_manager = PluginManager()
        Registry().register('mock_plugin', mocked_plugin)
        State().add_service("mock",
                            1,
                            is_plugin=True,
                            status=PluginStatus.Active)
        State().flush_preconditions()

        # WHEN: We run finalise_plugins()
        result = plugin_manager.get_plugin_by_name('Mocked Plugin')

        # THEN: The is_active() and finalise() methods should have been called
        assert result == mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin'