def test_find_and_configure_plugins_with_not_str_or_iterable(self):
        self.mock_get_option.return_value = 3

        plugins.find_and_configure_plugins("env_deployments")

        self.mock_get_option.assert_called_once_with('plugins')
        self.mock_get_class.assert_not_called()
    def test_find_and_configure_plugins_with_str(self):
        self.mock_get_option.return_value = "a"
        mock_callable1 = mock.Mock()
        self.mock_get_class.return_value = mock_callable1

        plugins.find_and_configure_plugins("env_deployments")

        self.mock_get_class.assert_called_once_with("a")
        mock_callable1.assert_called_once_with("env_deployments")
    def test_find_and_configure_plugins_with_list(self):
        self.mock_get_option.return_value = ["a", "b"]
        mock_callable1 = mock.Mock()
        mock_callable2 = mock.Mock()
        self.mock_get_class.side_effect = [mock_callable1, mock_callable2]

        plugins.find_and_configure_plugins("env_deployments")

        self.mock_get_class.assert_has_calls((mock.call("a"), mock.call("b")))
        mock_callable1.assert_called_once_with("env_deployments")
        mock_callable2.assert_called_once_with("env_deployments")
    def test_find_and_configure_plugins_plugin_raises_exception(self):
        self.mock_get_option.return_value = "a"

        def raises_(self):
            raise Exception("hello")

        mock_callable1 = mock.Mock()
        mock_callable1.side_effect = raises_
        self.mock_get_class.return_value = mock_callable1

        with self.assertRaises(Exception):
            plugins.find_and_configure_plugins("env_deployments")