示例#1
0
 def _load_really_all_providers(self):
     provider_list = []
     # StubBox is always enabled
     provider_list.append(
         Provider1.from_definition(get_stubbox_def(), secure=False))
     # Load all normal providers
     all_providers.load()
     provider_list.extend(all_providers.get_all_plugin_objects())
     return provider_list
示例#2
0
 def test_get_all_executables__without_bin_dir(self):
     """
     verify that Provider1.get_all_executables() returns an empty list if
     there the bin_dir is None.
     """
     provider = Provider1(
         self.NAME, self.VERSION, self.DESCRIPTION, self.SECURE,
         self.GETTEXT_DOMAIN, self.JOBS_DIR, self.WHITELISTS_DIR,
         self.DATA_DIR, None, self.LOCALE_DIR, self.BASE_DIR)
     self.assertEqual(provider.get_all_executables(), [])
示例#3
0
 def test_get_builtin_whitelists__without_whitelists_dir(self):
     """
     verify that Provider1.get_builtin_whitelist() returns an empty list if
     the whitelists_dir is None
     """
     provider = Provider1(
         self.NAME, self.VERSION, self.DESCRIPTION, self.SECURE,
         self.GETTEXT_DOMAIN, self.JOBS_DIR, None,
         self.DATA_DIR, self.BIN_DIR, self.LOCALE_DIR, self.BASE_DIR)
     self.assertEqual(provider.get_builtin_whitelists(), [])
示例#4
0
 def test_init_bindtextdomain__called(self, mock_gettext):
     """
     Verify that Provider1() calls bindtextdomain under certain
     circumstances
     """
     Provider1(self.NAME, self.NAMESPACE, self.VERSION, self.DESCRIPTION,
               self.SECURE, self.GETTEXT_DOMAIN, self.UNITS_DIR,
               self.JOBS_DIR, self.WHITELISTS_DIR, self.DATA_DIR,
               self.BIN_DIR, self.LOCALE_DIR, self.BASE_DIR)
     mock_gettext.bindtextdomain.assert_called_once_with(
         self.GETTEXT_DOMAIN, self.LOCALE_DIR)
示例#5
0
 def test_init_bindtextdomain__not_called(self, mock_gettext):
     """
     Verify that Provider1() calls bindtextdomain under certain
     circumstances
     """
     Provider1(
         self.NAME, self.NAMESPACE, self.VERSION, self.DESCRIPTION, self.SECURE,
         self.GETTEXT_DOMAIN, self.UNITS_DIR, self.JOBS_DIR,
         self.WHITELISTS_DIR, self.DATA_DIR, self.BIN_DIR, locale_dir=None,
         base_dir=self.BASE_DIR)
     self.assertEqual(mock_gettext.bindtextdomain.call_args_list, [])
示例#6
0
 def setUp(self):
     self.provider = Provider1(
         self.NAME, self.NAMESPACE, self.VERSION, self.DESCRIPTION, self.SECURE,
         self.GETTEXT_DOMAIN, self.UNITS_DIR, self.JOBS_DIR,
         self.WHITELISTS_DIR, self.DATA_DIR, self.BIN_DIR, self.LOCALE_DIR,
         self.BASE_DIR,
         # We are using dummy job definitions so let's not shout about those
         # being invalid in each test
         validate=False)
     self.fake_context = self.provider.fake([])
     self.fake_context.__enter__()
    def __init__(self,
                 filename,
                 file_contents,
                 load_time,
                 *,
                 validate=None,
                 validation_kwargs=None,
                 check=None,
                 context=None):
        """
        Initialize plug-in and create provider from definition extracted
        from manage.py pointed by `filename`
        """
        self._load_time = load_time
        # override provider_manager.setup() to capture setup's parameters
        setup_kwargs = []
        start_time = now()

        def fake_setup(**kwargs):
            setup_kwargs.append(kwargs)

        from plainbox import provider_manager
        provider_manager.setup = fake_setup

        loader = SourceFileLoader('manage', filename)
        loader.load_module()
        location = os.path.dirname(os.path.abspath(filename))
        if len(setup_kwargs) < 1:
            # did not load any provider from given manage.py
            # creating empty definition
            definition = Provider1Definition()
        else:
            setup_kwargs = setup_kwargs.pop()
            definition = Provider1Definition()
            definition.location = location
            definition.name = setup_kwargs.get('name', None)
            definition.namespace = setup_kwargs.get('namespace', Unset)
            definition.version = setup_kwargs.get('version', None)
            definition.description = setup_kwargs.get('description', None)
            definition.gettext_domain = setup_kwargs.get(
                'gettext_domain', Unset)
        self._provider = Provider1.from_definition(
            definition,
            secure=False,
            validate=validate,
            validation_kwargs=validation_kwargs,
            check=check,
            context=context)
        self._wrap_time = now() - start_time
示例#8
0
 def load_provider(self, manage_py):
     from plainbox import provider_manager
     from providerbackend import fake_provider_manager
     provider_manager.setup = fake_provider_manager.setup
     loader = SourceFileLoader('manage', manage_py)
     loader.load_module()
     if len(fake_provider_manager.all_setup_kwargs) == 0:
         raise ValueError("provider not defined")
     kwargs = fake_provider_manager.all_setup_kwargs.pop()
     location = os.path.dirname(os.path.abspath(manage_py))
     definition = Provider1Definition()
     definition.location = location
     definition.name = kwargs.get('name', None)
     definition.version = kwargs.get('version', None)
     definition.description = kwargs.get('description', None)
     definition.gettext_domain = kwargs.get('gettext_domain', Unset)
     return Provider1.from_definition(definition, secure=False)
示例#9
0
 def _load_stub_provider_only(self):
     return [Provider1.from_definition(get_stubbox_def(), secure=False)]
def get_manifest():
    return Provider1.from_definition(get_manifest_def(), secure=False)
def get_categories():
    return Provider1.from_definition(get_categories_def(), secure=False)
def get_stubbox(**kwargs):
    return Provider1.from_definition(get_stubbox_def(), secure=False, **kwargs)
def get_exporters():
    return Provider1.from_definition(get_exporters_def(), secure=False)
示例#14
0
 def get_provider(self):
     """
     Get a Provider1 that describes the current provider
     """
     return Provider1.from_definition(self.definition, secure=False)
示例#15
0
 def get_provider(self):
     """
     Get a Provider1 that describes the current provider
     """
     return Provider1.from_definition(self.definition, secure=False)
示例#16
0
 def setUp(self):
     self.provider = Provider1(
         self.NAME, self.VERSION, self.DESCRIPTION, self.SECURE,
         self.GETTEXT_DOMAIN, self.JOBS_DIR, self.WHITELISTS_DIR,
         self.DATA_DIR, self.BIN_DIR, self.LOCALE_DIR, self.BASE_DIR)