Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test using custom global var #297

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 3 additions & 41 deletions tests/integration/sources_test/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import dbt.tracking
import dbt.version
from dbt.events.functions import reset_metadata_vars
from tests.integration.base import DBTIntegrationTest, use_profile, AnyFloat, \
AnyStringWith

Expand Down Expand Up @@ -47,7 +48,7 @@ def run_dbt_with_vars(self, cmd, *args, **kwargs):
return self.run_dbt(cmd, *args, **kwargs)


class SuccessfulSourcesTest(BaseSourcesTest):
class TestSourceFreshness(BaseSourcesTest):
def setUp(self):
super().setUp()
self.run_dbt_with_vars(['seed'])
Expand Down Expand Up @@ -91,46 +92,6 @@ def _set_updated_at_to(self, delta):
self.last_inserted_time = insert_time.strftime(
"%Y-%m-%dT%H:%M:%S+00:00")


class TestSources(SuccessfulSourcesTest):
Copy link
Member Author

@emmyoop emmyoop Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually run any tests...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this code doesn't run tests. However, it seems the subsequent test relies on method overrides in SuccessfulSourcesTest. I don't know enough about this test to know exactly what it wants to cover. Obviously this needs to be revised when it gets ported away from the integration framework.

I'm gonna close this PR, but I stole your patch for this PR and credited you/this PR directly in the commit 😇

@property
def project_config(self):
cfg = super().project_config
cfg.update({
'macro-paths': ['macros'],
})
return cfg

def _create_schemas(self):
super()._create_schemas()
self._create_schema_named(self.default_database,
self.alternative_schema())

def alternative_schema(self):
return self.unique_schema() + '_other'

def setUp(self):
super().setUp()
self.run_sql(
'create table {}.dummy_table (id int)'.format(self.unique_schema())
)
self.run_sql(
'create view {}.external_view as (select * from {}.dummy_table)'
.format(self.alternative_schema(), self.unique_schema())
)

def run_dbt_with_vars(self, cmd, *args, **kwargs):
vars_dict = {
'test_run_schema': self.unique_schema(),
'test_run_alt_schema': self.alternative_schema(),
'test_loaded_at': self.adapter.quote('updated_at'),
}
cmd.extend(['--vars', yaml.safe_dump(vars_dict)])
return self.run_dbt(cmd, *args, **kwargs)


class TestSourceFreshness(SuccessfulSourcesTest):

def _assert_freshness_results(self, path, state):
self.assertTrue(os.path.exists(path))
with open(path) as fp:
Expand Down Expand Up @@ -216,4 +177,5 @@ def _run_source_freshness(self):

@use_profile('snowflake')
def test_snowflake_source_freshness(self):
reset_metadata_vars()
self._run_source_freshness()