Skip to content

Commit

Permalink
Merge pull request #1761 from fishtown-analytics/fix/fix-all-test-names
Browse files Browse the repository at this point in the history
Rename integration test methods to conform to standard
  • Loading branch information
beckjake authored Sep 17, 2019
2 parents f9bc7c5 + dbcb9c5 commit 0fa4523
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def seed_types(self):
}

@use_profile('postgres')
def test_simple_seed_with_column_override_postgres(self):
def test_postgres_simple_seed_with_column_override_postgres(self):
results = self.run_dbt(["seed", "--show"])
self.assertEqual(len(results), 1)
results = self.run_dbt(["test"])
Expand All @@ -63,7 +63,7 @@ def seed_types(self):
}

@use_profile('redshift')
def test_simple_seed_with_column_override_redshift(self):
def test_redshift_simple_seed_with_column_override_redshift(self):
results = self.run_dbt(["seed", "--show"])
self.assertEqual(len(results), 1)
results = self.run_dbt(["test"])
Expand All @@ -86,7 +86,7 @@ def profile_config(self):
return self.snowflake_profile()

@use_profile('snowflake')
def test_simple_seed_with_column_override_snowflake(self):
def test_snowflake_simple_seed_with_column_override_snowflake(self):
results = self.run_dbt(["seed", "--show"])
self.assertEqual(len(results), 1)
results = self.run_dbt(["test"])
Expand All @@ -109,7 +109,7 @@ def profile_config(self):
return self.bigquery_profile()

@use_profile('bigquery')
def test_simple_seed_with_column_override_bigquery(self):
def test_bigquery_simple_seed_with_column_override_bigquery(self):
results = self.run_dbt(["seed", "--show"])
self.assertEqual(len(results), 1)
results = self.run_dbt(["test"])
Expand Down
14 changes: 7 additions & 7 deletions test/integration/005_simple_seed_test/test_simple_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_seed(self):
def test_postgres_simple_seed(self):
results = self.run_dbt(["seed"])
self.assertEqual(len(results), 1)
self.assertTablesEqual("seed_actual","seed_expected")
Expand All @@ -39,7 +39,7 @@ def test_simple_seed(self):


@use_profile('postgres')
def test_simple_seed_with_drop(self):
def test_postgres_simple_seed_with_drop(self):
results = self.run_dbt(["seed"])
self.assertEqual(len(results), 1)
self.assertTablesEqual("seed_actual","seed_expected")
Expand Down Expand Up @@ -74,7 +74,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_seed_with_schema(self):
def test_postgres_simple_seed_with_schema(self):
schema_name = "{}_{}".format(self.unique_schema(), 'custom_schema')

results = self.run_dbt(["seed"])
Expand All @@ -88,7 +88,7 @@ def test_simple_seed_with_schema(self):


@use_profile('postgres')
def test_simple_seed_with_drop_and_schema(self):
def test_postgres_simple_seed_with_drop_and_schema(self):
schema_name = "{}_{}".format(self.unique_schema(), 'custom_schema')

results = self.run_dbt(["seed"])
Expand Down Expand Up @@ -128,7 +128,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_seed_with_disabled(self):
def test_postgres_simple_seed_with_disabled(self):
results = self.run_dbt(["seed"])
self.assertEqual(len(results), 1)
self.assertTableDoesExist('seed_enabled')
Expand Down Expand Up @@ -184,7 +184,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_seed(self):
def test_postgres_simple_seed(self):
# first make sure nobody "fixed" the file by accident
seed_path = os.path.join(self.config.data_paths[0], 'seed_bom.csv')
# 'data-bom/seed_bom.csv'
Expand Down Expand Up @@ -212,6 +212,6 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_seed(self):
def test_postgres_simple_seed(self):
results = self.run_dbt(["seed"])
self.assertEqual(len(results), 1)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_simple_dependency(self):
def test_postgres_simple_dependency(self):
self.run_dbt(["deps"])
results = self.run_dbt(["run"])
self.assertEqual(len(results), 5)
Expand Down Expand Up @@ -83,7 +83,7 @@ def project_config(self):


@use_profile('postgres')
def test_simple_dependency(self):
def test_postgres_simple_dependency(self):
self.run_dbt(["deps"])
results = self.run_dbt(["run"])
self.assertEqual(len(results), 5)
Expand Down Expand Up @@ -127,7 +127,7 @@ def project_config(self):


@use_profile('postgres')
def test_simple_dependency(self):
def test_postgres_simple_dependency(self):
self.use_default_project()

self.run_dbt(["deps"])
Expand Down Expand Up @@ -183,7 +183,7 @@ def project_config(self):


@use_profile('postgres')
def test_simple_dependency(self):
def test_postgres_simple_dependency(self):
self.run_dbt(["deps"])
results = self.run_dbt(["run"])
self.assertEqual(len(results), 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_schema_validations(self):
return test_task.run()

@use_profile('postgres')
def test_schema_tests(self):
def test_postgres_schema_tests(self):
results = self.run_dbt()
self.assertEqual(len(results), 5)
test_results = self.run_schema_validations()
Expand Down Expand Up @@ -77,7 +77,7 @@ def run_schema_validations(self):
return test_task.run()

@use_profile('postgres')
def test_malformed_schema_strict_will_break_run(self):
def test_postgres_malformed_schema_strict_will_break_run(self):
with self.assertRaises(CompilationException):
self.run_dbt(strict=True)
# even if strict = False!
Expand All @@ -104,7 +104,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_hooks_dont_run_for_tests(self):
def test_postgres_hooks_dont_run_for_tests(self):
# This would fail if the hooks ran
results = self.run_dbt(['test', '--model', 'ephemeral'])
self.assertEqual(len(results), 1)
Expand Down Expand Up @@ -162,7 +162,7 @@ def run_schema_validations(self):
return test_task.run()

@use_profile('postgres')
def test_schema_tests(self):
def test_postgres_schema_tests(self):
self.run_dbt(["deps"])
results = self.run_dbt()
self.assertEqual(len(results), 4)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/010_permission_tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def models(self):
return "models"

@use_profile('postgres')
def test_no_create_schema_permissions(self):
def test_postgres_no_create_schema_permissions(self):
# the noaccess user does not have permissions to create a schema -- this should fail
self.run_sql('drop schema if exists "{}" cascade'.format(self.unique_schema()))
with self.assertRaises(RuntimeError):
self.run_dbt(['run', '--target', 'noaccess'], expect_pass=False)

@use_profile('postgres')
def test_create_schema_permissions(self):
def test_postgres_create_schema_permissions(self):
# now it should work!
self.run_sql('grant create on database {} to noaccess'.format(self.default_database))
self.run_sql('grant usage, create on schema "{}" to noaccess'.format(self.unique_schema()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def models(self):
return "models-2"

@use_profile('postgres')
def test_view_with_incremental_attributes(self):
def test_postgres_view_with_incremental_attributes(self):
with self.assertRaises(RuntimeError) as exc:
self.run_dbt()

Expand All @@ -40,7 +40,7 @@ def models(self):
return "models-3"

@use_profile('postgres')
def test_view_with_incremental_attributes(self):
def test_postgres_view_with_incremental_attributes(self):
with self.assertRaises(RuntimeError) as exc:
self.run_dbt()

Expand Down
4 changes: 2 additions & 2 deletions test/integration/013_context_var_tests/test_context_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_ctx_vars(self):
return ctx

@use_profile('postgres')
def test_env_vars_dev(self):
def test_postgres_env_vars_dev(self):
results = self.run_dbt(['run'])
self.assertEqual(len(results), 1)
ctx = self.get_ctx_vars()
Expand All @@ -110,7 +110,7 @@ def test_env_vars_dev(self):
self.assertEqual(ctx['env_var'], '1')

@use_profile('postgres')
def test_env_vars_prod(self):
def test_postgres_env_vars_prod(self):
results = self.run_dbt(['run', '--target', 'prod'])
self.assertEqual(len(results), 1)
ctx = self.get_ctx_vars()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def models(self):
return "models"

@use_profile('postgres')
def test_toplevel_dbt_run(self):
def test_postgres_toplevel_dbt_run(self):
results = self.run_dbt(['run'])
self.assertEqual(len(results), 1)
self.assertTablesEqual("seed", "model")

@use_profile('postgres')
def test_subdir_dbt_run(self):
def test_postgres_subdir_dbt_run(self):
os.chdir(os.path.join(self.models, "subdir1"))

results = self.run_dbt(['run'])
Expand Down Expand Up @@ -97,7 +97,7 @@ def models(self):
return "models"

@use_profile('postgres')
def test_toplevel_dbt_run_with_profile_dir_arg(self):
def test_postgres_toplevel_dbt_run_with_profile_dir_arg(self):
results = self.run_dbt(['run', '--profiles-dir', 'dbt-profile'], profiles_dir=False)
self.assertEqual(len(results), 1)

Expand Down
4 changes: 2 additions & 2 deletions test/integration/016_macro_tests/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_working_macros(self):
def test_postgres_working_macros(self):
self.run_dbt(["deps"])
results = self.run_dbt(["run"])
self.assertEqual(len(results), 6)
Expand Down Expand Up @@ -64,7 +64,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_invalid_macro(self):
def test_postgres_invalid_macro(self):

try:
self.run_dbt(["run"], expect_pass=False)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/019_analysis_tests/test_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def assert_contents_equal(self, path, expected):
self.assertEqual(fp.read().strip(), expected)

@use_profile('postgres')
def test_analyses(self):
def test_postgres_analyses(self):
compiled_analysis_path = os.path.normpath('target/compiled/test/analysis')
path_1 = os.path.join(compiled_analysis_path, 'analysis.sql')
path_2 = os.path.join(compiled_analysis_path, 'raw_stuff.sql')
Expand Down
12 changes: 6 additions & 6 deletions test/integration/023_exit_codes_test/test_exit_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def schema(self):
def models(self):
return "models"


@property
def project_config(self):
return {
Expand Down Expand Up @@ -66,6 +65,7 @@ def test__postgres_snapshot_pass(self):
self.assertTableDoesExist('good_snapshot')
self.assertTrue(success)


class TestExitCodesSnapshotFail(DBTIntegrationTest):

@property
Expand All @@ -83,7 +83,7 @@ def project_config(self):
}

@use_profile('postgres')
def test___snapshot_fail(self):
def test__postgres_snapshot_fail(self):
results, success = self.run_dbt_and_check(['run', '--model', 'good'])
self.assertTrue(success)
self.assertEqual(len(results.results), 1)
Expand Down Expand Up @@ -112,7 +112,7 @@ def packages_config(self):
}

@use_profile('postgres')
def test_deps(self):
def test_postgres_deps(self):
_, success = self.run_dbt_and_check(['deps'])
self.assertTrue(success)

Expand All @@ -138,7 +138,7 @@ def packages_config(self):
}

@use_profile('postgres')
def test_deps(self):
def test_postgres_deps(self):
with self.assertRaises(dbt.exceptions.InternalException):
# this should fail
self.run_dbt_and_check(['deps'])
Expand All @@ -160,7 +160,7 @@ def project_config(self):
}

@use_profile('postgres')
def test_seed(self):
def test_postgres_seed(self):
results, success = self.run_dbt_and_check(['seed'])
self.assertEqual(len(results.results), 1)
self.assertTrue(success)
Expand All @@ -182,6 +182,6 @@ def project_config(self):
}

@use_profile('postgres')
def test_seed(self):
def test_postgres_seed(self):
_, success = self.run_dbt_and_check(['seed'])
self.assertFalse(success)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def profile_config(self):
}

@use_profile("postgres")
def test_duplicate_model_enabled(self):
def test_postgres_duplicate_model_enabled(self):
message = "dbt found two resources with the name"
try:
self.run_dbt(["run"])
Expand Down Expand Up @@ -73,7 +73,7 @@ def profile_config(self):
}

@use_profile("postgres")
def test_duplicate_model_disabled(self):
def test_postgres_duplicate_model_disabled(self):
try:
results = self.run_dbt(["run"])
except CompilationException:
Expand Down Expand Up @@ -109,7 +109,7 @@ def packages_config(self):
}

@use_profile("postgres")
def test_duplicate_model_enabled_across_packages(self):
def test_postgres_duplicate_model_enabled_across_packages(self):
self.run_dbt(["deps"])
message = "dbt found two resources with the name"
try:
Expand Down Expand Up @@ -146,7 +146,7 @@ def packages_config(self):
}

@use_profile("postgres")
def test_duplicate_model_disabled_across_packages(self):
def test_postgres_duplicate_model_disabled_across_packages(self):
self.run_dbt(["deps"])
try:
self.run_dbt(["run"])
Expand Down
2 changes: 1 addition & 1 deletion test/integration/025_timezones_test/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def query(self):

@freeze_time("2017-01-01 03:00:00", tz_offset=0)
@use_profile('postgres')
def test_run_started_at(self):
def test_postgres_run_started_at(self):
results = self.run_dbt(['run'])
self.assertEqual(len(results), 1)
result = self.run_sql(self.query, fetch='all')[0]
Expand Down
Loading

0 comments on commit 0fa4523

Please sign in to comment.