ashb commented on a change in pull request #5841: [AIRFLOW-3705] Fix
PostgresHook get_conn to use conn_name_attr
URL: https://github.com/apache/airflow/pull/5841#discussion_r316688934
##########
File path: tests/hooks/test_postgres_hook.py
##########
@@ -39,7 +39,10 @@ def setUp(self):
schema='schema'
)
- self.db_hook = PostgresHook()
+ class UnitTestPostgresHook(PostgresHook):
+ conn_name_attr = 'test_conn_id'
Review comment:
Something like this:
```python
@mock.patch('airflow.hooks.postgres_hook.psycopg2.connect')
def test_get_conn_non_default_id(self, mock_connect):
self.db_hook.test_conn_id = "non_default"
self.db_hook.get_conn()
mock_connect.assert_called_once_with(user='login',
password='password', host='host',
dbname='schema', port=None)
self.db_hook.get_connection.assert_called_once_with("non_default")
```
That way it is a little bit more explicit (and easier to track down if it
breaks).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services