def index(self):
     """ Create new environment, fill it, and create an IndexAPI
     """
     from docido_sdk.index.config import YamlPullCrawlersIndexingConfig
     with unregister_component(YamlPullCrawlersIndexingConfig):
         # `YamlPullCrawlersIndexingConfig` is hidden from Environment
         # instances in this context thanks to `unregister_component`.
         # This is required because this class uses a custom component
         # implementing `IndexPipelineConfig`, which is also the case of
         # `YamlPullCrawlersIndexingConfig`. But there must be only one.
         env = Environment()
         env.temp_dir = tempfile.mkdtemp()
         test_components = self._setup_test_components(env)
         pipeline = env[IndexPipelineProvider]
         try:
             # build and provide an IndexAPI
             yield pipeline.get_index_api(None, None, None)
         finally:
             # Hide from Environment the Component classes defined
             # for this test only.
             for test_component in test_components:
                 test_component.unregister()
             # Remove temporary directory previously created
             if osp.isdir(env.temp_dir):
                 shutil.rmtree(env.temp_dir)
示例#2
0
 def index(self):
     """ Create new environment, fill it, and create an IndexAPI
     """
     from docido_sdk.index.config import YamlPullCrawlersIndexingConfig
     with unregister_component(YamlPullCrawlersIndexingConfig):
         env = Environment()
         env.temp_dir = tempfile.mkdtemp()
         test_components = self._setup_test_components(env)
         pipeline = env[IndexPipelineProvider]
         try:
             # build and provide an IndexAPI
             yield pipeline.get_index_api(None, None, None, None)
         finally:
             # Hide from Environment the Component classes defined
             # for this test only.
             for test_component in test_components:
                 test_component.unregister()
                 # Remove temporary directory previously created
                 if osp.isdir(env.temp_dir):
                     shutil.rmtree(env.temp_dir)
 def index(self):
     """ Create new environment, fill it, and create an IndexAPI
     """
     from docido_sdk.index.config import YamlPullCrawlersIndexingConfig
     with unregister_component(YamlPullCrawlersIndexingConfig):
         env = Environment()
         env.temp_dir = tempfile.mkdtemp()
         test_components = self._setup_test_components(env)
         pipeline = env[IndexPipelineProvider]
         try:
             # build and provide an IndexAPI
             yield pipeline.get_index_api(None, None, None)
         finally:
             # Hide from Environment the Component classes defined
             # for this test only.
             for test_component in test_components:
                 test_component.unregister()
                 # Remove temporary directory previously created
                 if osp.isdir(env.temp_dir):
                     shutil.rmtree(env.temp_dir)
示例#4
0
    def kv(self):
        from docido_sdk.index.config import YamlPullCrawlersIndexingConfig
        with unregister_component(YamlPullCrawlersIndexingConfig):
            env = Environment()
            env.temp_dir = tempfile.mkdtemp()

            class ForcePipeline(Component):
                implements(IndexPipelineConfig)

                def get_pipeline(self, *args, **kwargs):
                    return [env[LocalKV]]

            class ForceConfig(Component):
                implements(IndexAPIConfigurationProvider)

                def get_index_api_conf(self, service, docido_user_id,
                                       account_login, config):
                    return {
                        'local_storage': {
                            'documents': {
                                'path': env.temp_dir,
                            },
                            'kv': {
                                'path': env.temp_dir,
                            },
                        },
                    }

            env[ForcePipeline]
            env[ForceConfig]
            pipeline = env[IndexPipelineProvider]
            try:
                yield pipeline.get_index_api(None, None, None, None)
            finally:
                ForcePipeline.unregister()
                ForceConfig.unregister()
                if osp.isdir(env.temp_dir):
                    shutil.rmtree(env.temp_dir)
    def kv(self):
        from docido_sdk.index.config import YamlPullCrawlersIndexingConfig
        with unregister_component(YamlPullCrawlersIndexingConfig):
            env = Environment()
            env.temp_dir = tempfile.mkdtemp()

            class ForcePipeline(Component):
                implements(IndexPipelineConfig)

                def get_pipeline(self):
                    return [env[LocalKV]]

            class ForceConfig(Component):
                implements(IndexAPIConfigurationProvider)

                def get_index_api_conf(self, service,
                                       docido_user_id, account_login):
                    return {
                        'local_storage': {
                            'documents': {
                                'path': env.temp_dir,
                            },
                            'kv': {
                                'path': env.temp_dir,
                            },
                        },
                    }
            env[ForcePipeline]
            env[ForceConfig]
            pipeline = env[IndexPipelineProvider]
            try:
                yield pipeline.get_index_api(None, None, None)
            finally:
                ForcePipeline.unregister()
                ForceConfig.unregister()
                if osp.isdir(env.temp_dir):
                    shutil.rmtree(env.temp_dir)