Skip to content

Commit

Permalink
added tests and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed Oct 1, 2020
1 parent 1eefced commit 0af9a34
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added schema and dbt versions to JSON artifacts ([#2670](https:/fishtown-analytics/dbt/issues/2670), [#2767](https:/fishtown-analytics/dbt/pull/2767))
- Added ability to snapshot hard-deleted records (opt-in with `invalidate_hard_deletes` config option). ([#249](https:/fishtown-analytics/dbt/issues/249), [#2749](https:/fishtown-analytics/dbt/pull/2749))
- Improved error messages for YAML selectors ([#2700](https:/fishtown-analytics/dbt/issues/2700), [#2781](https:/fishtown-analytics/dbt/pull/2781))
- Added support for BigQuery connections using refresh tokens ([#2344](https:/fishtown-analytics/dbt/issues/2344), [#2805](https:/fishtown-analytics/dbt/pull/2805))

### Under the hood
- Added strategy-specific validation to improve the relevancy of compilation errors for the `timestamp` and `check` snapshot strategies. (([#2787](https:/fishtown-analytics/dbt/issues/2787), [#2791](https:/fishtown-analytics/dbt/pull/2791))
Expand Down
31 changes: 31 additions & 0 deletions test/unit/test_bigquery_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ def setUp(self):
'threads': 1,
'impersonate_service_account': '[email protected]'
},
'oauth-credentials': {
'type': 'bigquery',
'method': 'bearer',
'client_id': 'abc',
'client_secret': 'def',
'refresh_token': 'ghi',
'token_uri': 'jkl'
'project': 'dbt-unit-000000',
'schema': 'dummy_schema',
'threads': 1,
'location': 'Luna Station',
'priority': 'batch',
'maximum_bytes_billed': 0,
},
},
'target': 'oauth',
}
Expand Down Expand Up @@ -145,6 +159,23 @@ def test_acquire_connection_service_account_validations(self, mock_open_connecti
connection.handle
mock_open_connection.assert_called_once()

@patch('dbt.adapters.bigquery.BigQueryConnectionManager.open', return_value=_bq_conn())
def test_acquire_connection_service_account_validations(self, mock_open_connection):
adapter = self.get_adapter('oauth-credentials')
try:
connection = adapter.acquire_connection('dummy')
self.assertEqual(connection.type, 'bigquery')

except dbt.exceptions.ValidationException as e:
self.fail('got ValidationException: {}'.format(str(e)))

except BaseException as e:
raise

mock_open_connection.assert_not_called()
connection.handle
mock_open_connection.assert_called_once()

@patch('dbt.adapters.bigquery.BigQueryConnectionManager.open', return_value=_bq_conn())
def test_acquire_connection_impersonated_service_account_validations(self, mock_open_connection):
adapter = self.get_adapter('impersonate')
Expand Down

0 comments on commit 0af9a34

Please sign in to comment.