def tearDown(self): self.write_gpickle_patcher.stop() self.load_projects_patcher.stop() self.file_system_patcher.stop() self.get_adapter_patcher.stop() self.get_adapter_patcher_parser.stop() self.mock_filesystem_constructor.stop() self.mock_hook_constructor.stop() self.load_state_check.stop() self.load_source_file_patcher.stop() reset_adapters()
def tearDown(self): self._clean_files() if not hasattr(self, 'adapter'): self.adapter = get_adapter(self.config) self._drop_schema() # hack for BQ -- TODO if hasattr(self.handle, 'close'): self.handle.close() self.adapter.cleanup_connections() reset_adapters()
def run_dbt(self, args=None, expect_pass=True, strict=True): # clear the adapter cache reset_adapters() if args is None: args = ["run"] if strict: args = ["--strict"] + args logger.info("Invoking dbt with {}".format(args)) res, success = dbt.handle_and_check(args) self.assertEqual(success, expect_pass, "dbt exit state did not match expected") return res
def tearDown(self): self._clean_files() # get any current run adapter and clean up its connections before we # reset them. It'll probably be different from ours because # handle_and_check() calls reset_adapters(). adapter = get_adapter(self.config) if adapter is not self.adapter: adapter.cleanup_connections() if not hasattr(self, 'adapter'): self.adapter = adapter self._drop_schemas() self.adapter.cleanup_connections() reset_adapters()
def tearDown(self): self._clean_files() # get any current run adapter and clean up its connections before we # reset them. It'll probably be different from ours because # handle_and_check() calls reset_adapters(). adapter = get_adapter(self.config) if adapter is not self.adapter: adapter.cleanup_connections() if not hasattr(self, 'adapter'): self.adapter = adapter self._drop_schemas() self.adapter.cleanup_connections() reset_adapters()
def handle_and_check(args): parsed = parse_args(args) profiler_enabled = False if parsed.record_timing_info: profiler_enabled = True with dbt.profiler.profiler(enable=profiler_enabled, outfile=parsed.record_timing_info): initialize_config_values(parsed) reset_adapters() task, res = run_from_args(parsed) success = task.interpret_results(res) return res, success
def setUp(self): self.database = os.getenv('DBT_MODEL_TEST_DATABASE') self.schema = os.getenv('DBT_MODEL_TEST_SCHEMA') self.identifier_prefix = os.getenv('DBT_MODEL_TEST_IDENTIFIER_PREFIX') reset_adapters() kwargs = { 'profile': 'modeltests', 'profiles_dir': 'conf/', 'target': None, } config = RuntimeConfig.from_args(TestArgs(kwargs)) register_adapter(config) adapter = get_adapter(config) adapter.cleanup_connections() self.adapter = adapter
def tearDown(self): # get any current run adapter and clean up its connections before we # reset them. It'll probably be different from ours because # handle_and_check() calls reset_adapters(). register_adapter(self.config) adapter = get_adapter(self.config) if adapter is not self.adapter: adapter.cleanup_connections() if not hasattr(self, 'adapter'): self.adapter = adapter self._drop_schemas() self.adapter.cleanup_connections() reset_adapters() os.chdir(INITIAL_ROOT) try: shutil.rmtree(self.test_root_dir) except EnvironmentError: logger.exception('Could not clean up after test - {} not removable' .format(self.test_root_dir))
def adapter_management(): reset_adapters() try: yield finally: cleanup_connections()
def reload_config(self): config = self.config.from_args(self.args) self.config = config reset_adapters() register_adapter(config) return config