Exemplo n.º 1
0
 def test_update_package_source_from_config__normal_case(self):
     source_configs = [{
         'name': '1',
         'type': 'git'
     }, {
         'name': '2',
         'type': 'git'
     }, {
         'name': '3',
         'type': 's3'
     }, {
         'name': '4',
         'type': 'fs'
     }]
     ExternalPackageSource.update_package_source_from_config(source_configs)
     GitRepoSource.objects.update_source_from_config.assert_has_calls([
         call(configs=[{
             'name': '3'
         }]),
         call(configs=[{
             'name': '1'
         }, {
             'name': '2'
         }]),
         call(configs=[{
             'name': '4'
         }])
     ])
Exemplo n.º 2
0
 def test_update_source_from_config__name_conflict(self):
     source = deepcopy(SOURCE_1)
     source['type'] = 'git'
     ExternalPackageSource.update_package_source_from_config([source])
     GitRepoSource.objects.filter(name=source['name']).update(
         from_config=False)
     self.assertRaises(
         exceptions.InvalidOperationException,
         ExternalPackageSource.update_package_source_from_config, [source])
Exemplo n.º 3
0
    def ready(self):
        from pipeline.contrib.external_plugins import loader  # noqa
        from pipeline.contrib.external_plugins.models import ExternalPackageSource  # noqa

        # load external components when start command in trigger list
        if self.should_load_external_module():
            try:
                logger.info(
                    'Start to update package source from config file...')
                ExternalPackageSource.update_package_source_from_config(
                    getattr(settings, 'COMPONENTS_PACKAGE_SOURCES', {}))
            except ProgrammingError:
                logger.warning(
                    'update package source failed, maybe first migration? '
                    'exception: {traceback}'.format(
                        traceback=traceback.format_exc()))
                # first migrate
                return

            logger.info('Start to load external modules...')

            loader.load_external_modules()
Exemplo n.º 4
0
 def test_update_package_source_from_config__empty_configs(self):
     ExternalPackageSource.update_package_source_from_config([])
     for source_model_cls in source_cls_factory.values():
         source_model_cls.objects.update_source_from_config.assert_called_with(
             configs=[])