Skip to content

Commit

Permalink
Merge pull request #1578 from heisencoder/fix/test-cleanup
Browse files Browse the repository at this point in the history
Fix/test cleanup
  • Loading branch information
beckjake authored Jun 27, 2019
2 parents 42fb120 + 2f1dbc2 commit f368820
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ def swap_types_and_test(self):
# between materializations that create tables and views.

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: table'])
self.assertEquals(results[0].node['config']['materialized'], 'table')
self.assertEqual(results[0].node['config']['materialized'], 'table')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: incremental'])
self.assertEquals(results[0].node['config']['materialized'], 'incremental')
self.assertEqual(results[0].node['config']['materialized'], 'incremental')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

@use_profile("postgres")
Expand All @@ -59,37 +59,37 @@ def test__bigquery__switch_materialization(self):
# and then remove these bq-specific tests

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: table'])
self.assertEquals(results[0].node['config']['materialized'], 'table')
self.assertEqual(results[0].node['config']['materialized'], 'table')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: view', "--full-refresh"])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: incremental'])
self.assertEquals(results[0].node['config']['materialized'], 'incremental')
self.assertEqual(results[0].node['config']['materialized'], 'incremental')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: view', "--full-refresh"])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

@use_profile('presto')
def test__presto__switch_materialization(self):
# presto can't do incremental materializations so there's less to this

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: table'])
self.assertEquals(results[0].node['config']['materialized'], 'table')
self.assertEqual(results[0].node['config']['materialized'], 'table')
self.assertEqual(len(results), 1)

results = self.run_dbt(['run', '--vars', 'materialized: view'])
self.assertEquals(results[0].node['config']['materialized'], 'view')
self.assertEqual(results[0].node['config']['materialized'], 'view')
self.assertEqual(len(results), 1)
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def tearDown(self):

@use_profile('postgres')
def test__postgres__external_reference(self):
self.assertEquals(len(self.run_dbt()), 1)
self.assertEqual(len(self.run_dbt()), 1)
# running it again should succeed
self.assertEquals(len(self.run_dbt()), 1)
self.assertEqual(len(self.run_dbt()), 1)


# The opposite of the test above -- check that external relations that
Expand All @@ -61,7 +61,7 @@ def tearDown(self):

@use_profile('postgres')
def test__postgres__external_reference(self):
self.assertEquals(len(self.run_dbt()), 1)
self.assertEqual(len(self.run_dbt()), 1)

# create a view outside of the dbt schema that depends on this model
self.external_schema = self.unique_schema()+'zz'
Expand All @@ -74,5 +74,5 @@ def test__postgres__external_reference(self):
)

# running it again should succeed
self.assertEquals(len(self.run_dbt()), 1)
self.assertEqual(len(self.run_dbt()), 1)

4 changes: 2 additions & 2 deletions test/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def _assertTableRowCountsEqual(self, relation_a, relation_b):

res = self.run_sql(cmp_query, fetch='one')

self.assertEquals(int(res[0]), 0, "Row count of table {} doesn't match row count of table {}. ({} rows different)".format(
self.assertEqual(int(res[0]), 0, "Row count of table {} doesn't match row count of table {}. ({} rows different)".format(
relation_a.identifier,
relation_b.identifier,
res[0]
Expand All @@ -1045,7 +1045,7 @@ def _assertTableRowCountsEqual(self, relation_a, relation_b):
def assertTableDoesNotExist(self, table, schema=None):
columns = self.get_table_columns(table, schema)

self.assertEquals(
self.assertEqual(
len(columns),
0
)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_bigquery_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_acquire_connection_oauth_validations(self, mock_open_connection):
adapter = self.get_adapter('oauth')
try:
connection = adapter.acquire_connection('dummy')
self.assertEquals(connection.get('type'), 'bigquery')
self.assertEqual(connection.get('type'), 'bigquery')

except dbt.exceptions.ValidationException as e:
self.fail('got ValidationException: {}'.format(str(e)))
Expand All @@ -94,7 +94,7 @@ def test_acquire_connection_service_account_validations(self, mock_open_connecti
adapter = self.get_adapter('service_account')
try:
connection = adapter.acquire_connection('dummy')
self.assertEquals(connection.get('type'), 'bigquery')
self.assertEqual(connection.get('type'), 'bigquery')

except dbt.exceptions.ValidationException as e:
self.fail('got ValidationException: {}'.format(str(e)))
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dbt.contracts.graph.parsed import ParsedNode
from dbt.context import parser, runtime
import dbt.exceptions
from test.unit.mock_adapter import adapter_factory
from .mock_adapter import adapter_factory



Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_graph_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run_specs_and_assert(self, graph, include, exclude, expected):
exclude
)

self.assertEquals(selected, expected)
self.assertEqual(selected, expected)


def test__single_node_selection_in_package(self):
Expand Down Expand Up @@ -177,7 +177,7 @@ def test__package_name_getter(self):
found = graph_selector.get_package_names(self.package_graph)

expected = set(['X', 'Y'])
self.assertEquals(found, expected)
self.assertEqual(found, expected)

def assert_is_selected_node(self, node, spec, should_work):
self.assertEqual(
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_postgres_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def test_acquire_connection_validations(self, psycopg2):
except BaseException as e:
self.fail('acquiring connection failed with unknown exception: {}'
.format(str(e)))
self.assertEquals(connection.type, 'postgres')
self.assertEqual(connection.type, 'postgres')
psycopg2.connect.assert_called_once()

@mock.patch('dbt.adapters.postgres.connections.psycopg2')
def test_acquire_connection(self, psycopg2):
connection = self.adapter.acquire_connection('dummy')

self.assertEquals(connection.state, 'open')
self.assertNotEquals(connection.handle, None)
self.assertEqual(connection.state, 'open')
self.assertNotEqual(connection.handle, None)
psycopg2.connect.assert_called_once()

def test_cancel_open_connections_empty(self):
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_redshift_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def adapter(self):

def test_implicit_database_conn(self):
creds = RedshiftAdapter.ConnectionManager.get_credentials(self.config.credentials)
self.assertEquals(creds, self.config.credentials)
self.assertEqual(creds, self.config.credentials)

def test_explicit_database_conn(self):
self.config.method = 'database'

creds = RedshiftAdapter.ConnectionManager.get_credentials(self.config.credentials)
self.assertEquals(creds, self.config.credentials)
self.assertEqual(creds, self.config.credentials)

def test_explicit_iam_conn(self):
self.config.credentials = self.config.credentials.incorporate(
Expand All @@ -80,7 +80,7 @@ def test_explicit_iam_conn(self):
creds = RedshiftAdapter.ConnectionManager.get_credentials(self.config.credentials)

expected_creds = self.config.credentials.incorporate(password='tmp_password')
self.assertEquals(creds, expected_creds)
self.assertEqual(creds, expected_creds)

def test_invalid_auth_method(self):
# we have to set method this way, otherwise it won't validate
Expand Down
16 changes: 8 additions & 8 deletions test/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test__simple_cases(self):

for case in cases:
actual = dbt.utils.deep_merge(*case['args'])
self.assertEquals(
self.assertEqual(
case['expected'], actual,
'failed on {} (actual {}, expected {})'.format(
case['description'], actual, case['expected']))
Expand All @@ -38,7 +38,7 @@ def test__simple_cases(self):

for case in cases:
actual = dbt.utils.deep_merge(*case['args'])
self.assertEquals(
self.assertEqual(
case['expected'], actual,
'failed on {} (actual {}, expected {})'.format(
case['description'], actual, case['expected']))
Expand Down Expand Up @@ -88,10 +88,10 @@ def test__simple_cases(self):
],
}
actual = dbt.utils.deep_map(self.intify_all, self.input_value)
self.assertEquals(actual, expected)
self.assertEqual(actual, expected)

actual = dbt.utils.deep_map(self.intify_all, expected)
self.assertEquals(actual, expected)
self.assertEqual(actual, expected)


@staticmethod
Expand Down Expand Up @@ -121,20 +121,20 @@ def test__keypath(self):
],
}
actual = dbt.utils.deep_map(self.special_keypath, self.input_value)
self.assertEquals(actual, expected)
self.assertEqual(actual, expected)

actual = dbt.utils.deep_map(self.special_keypath, expected)
self.assertEquals(actual, expected)
self.assertEqual(actual, expected)

def test__noop(self):
actual = dbt.utils.deep_map(lambda x, _: x, self.input_value)
self.assertEquals(actual, self.input_value)
self.assertEqual(actual, self.input_value)

def test_trivial(self):
cases = [[], {}, 1, 'abc', None, True]
for case in cases:
result = dbt.utils.deep_map(lambda x, _: x, case)
self.assertEquals(result, case)
self.assertEqual(result, case)

with self.assertRaises(dbt.exceptions.DbtConfigError):
dbt.utils.deep_map(lambda x, _: x, {'foo': object()})
Expand Down

0 comments on commit f368820

Please sign in to comment.