def test_env_error(self): try: tmpdir = tempfile.mkdtemp() envvar = 'TestConfigurationSettings' os.environ[envvar] = tmpdir with self.assertRaises(IOError): Configuration.from_env(envvar, None, {}) finally: shutil.rmtree(tmpdir)
def _test_config(cls): """Provides content of .yml file named after the Python module where the class extending this class is defined. """ module_path = sys.modules[cls.__module__].__file__ yaml_path = osp.splitext(module_path)[0] + '.yml' return Configuration.from_file(yaml_path)
def index(self): """ Create new environment, fill it, and create an IndexAPI """ from docido_sdk.index.config import YamlPullCrawlersIndexingConfig config_yaml = osp.splitext(__file__)[0] + '.yml' with docido_config: docido_config.clear() docido_config.update(Configuration.from_file(config_yaml)) env = Environment() env.temp_dir = tempfile.mkdtemp() test_components = self._setup_test_components(env) pipeline = env[IndexPipelineProvider] env[Elasticsearch] try: # build and provide an IndexAPI env[YamlPullCrawlersIndexingConfig] 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 run_crawl(self, cls, *args, **kwargs): with restore_dict_kv(os.environ, 'DOCIDO_CC_RUNS'), \ docido_config, \ self.crawler(cls, *args, **kwargs), \ self.check_crawl(*args, **kwargs): config_prefix = osp.splitext(__file__)[0] os.environ['DOCIDO_CC_RUNS'] = config_prefix + '-runs.yml' config_settings = config_prefix + '-settings.yml' docido_config.update(Configuration.from_file(config_settings)) for c in dcc_run.run([], environment=Environment()): shutil.rmtree(c['crawl_path'])
def index(self): from docido_sdk.index.config import YamlPullCrawlersIndexingConfig config_yaml = osp.splitext(__file__)[0] + '.yml' with docido_config: docido_config.clear() docido_config.update(Configuration.from_file(config_yaml)) env = Environment() test_components = self._setup_test_components(env) env[IndexPipelineProvider] env[LocalDumbIndex] env[processor.CheckProcessor] try: env[YamlPullCrawlersIndexingConfig] index_builder = env[IndexPipelineProvider] yield index_builder.get_index_api('check-processor-test', 'user2', 'account3', None) finally: for test_component in test_components: test_component.unregister()
def index(self): from docido_sdk.index.config import YamlPullCrawlersIndexingConfig config_yaml = osp.splitext(__file__)[0] + '.yml' with docido_config: docido_config.clear() docido_config.update(Configuration.from_file(config_yaml)) env = Environment() test_components = self._setup_test_components(env) env[IndexPipelineProvider] env[LocalDumbIndex] env[processor.CheckProcessor] try: env[YamlPullCrawlersIndexingConfig] index_builder = env[IndexPipelineProvider] yield index_builder.get_index_api( 'check-processor-test', 'user2', 'account3' ) finally: for test_component in test_components: test_component.unregister()