Skip to content

Commit

Permalink
Fire events in tests.integration.base instead of AdapterLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Nov 18, 2021
1 parent 47965fe commit 587f5e8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
from dbt.events.functions import (
capture_stdout_logs, fire_event, setup_event_logger, stop_capture_stdout_logs
)
from dbt.events import AdapterLogger
from dbt.events.test_types import (
IntegrationTestInfo,
IntegrationTestDebug,
IntegrationTestException
)
from dbt.contracts.graph.manifest import Manifest


logger = AdapterLogger("Snowflake")
INITIAL_ROOT = os.getcwd()


Expand Down Expand Up @@ -272,7 +275,7 @@ def setUp(self):
'test_original_source_path={0.test_original_source_path}',
'test_root_dir={0.test_root_dir}'
)).format(self)
logger.exception(msg)
fire_event(IntegrationTestException(msg=msg))

# if logging isn't set up, I still really want this message.
print(msg)
Expand Down Expand Up @@ -382,8 +385,8 @@ def tearDown(self):
try:
shutil.rmtree(self.test_root_dir)
except EnvironmentError:
logger.exception('Could not clean up after test - {} not removable'
.format(self.test_root_dir))
msg = f"Could not clean up after test - {self.test_root_dir} not removable"
fire_event(IntegrationTestException(msg=msg))

def _get_schema_fqn(self, database, schema):
schema_fqn = self.quote_as_configured(schema, 'schema')
Expand Down Expand Up @@ -479,7 +482,8 @@ def run_dbt_and_check(self, args=None, profiles_dir=True):
final_args.extend(['--profiles-dir', self.test_root_dir])
final_args.append('--log-cache-events')

logger.info("Invoking dbt with {}".format(final_args))
msg = f"Invoking dbt with {final_args}"
fire_event(IntegrationTestInfo(msg=msg))
return dbt.handle_and_check(final_args)

def run_sql_file(self, path, kwargs=None):
Expand Down Expand Up @@ -537,7 +541,8 @@ def run_sql(self, query, fetch='None', kwargs=None, connection_name=None):
sql = self.transform_sql(query, kwargs=kwargs)

with self.get_connection(connection_name) as conn:
logger.debug('test connection "{}" executing: {}'.format(conn.name, sql))
msg = f'test connection "{conn.name}" executing: {sql}'
fire_event(IntegrationTestDebug(msg=msg))
return self.run_sql_common(sql, fetch, conn)

def _ilike(self, target, value):
Expand Down

0 comments on commit 587f5e8

Please sign in to comment.