You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/08/21 19:43:16 UTC

[GitHub] [airflow] coopergillan commented on a change in pull request #5841: [AIRFLOW-3705] Fix PostgresHook get_conn to use conn_name_attr

coopergillan 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_r316368793
 
 

 ##########
 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:
   Once I had tried a few things, I ended up with this test-driven development path:
   
   1. Make the change above
   2. Run `tests/hooks/test_postgres_hook.py` and get this error (also in the PR description):
   ``python
   AttributeError: 'UnitTestPostgresHook' object has no attribute 'postgres_conn_id'
   ```
   3. Make the change to `airflow/hooks/postgres_hook.py` to call the `conn_name_attr` rather than directly calling `postgres_conn_id`
   4. See the tests pass
   
   I think I what you called out sounds right-on: there is a `conn_name_attr` used for connecting to any database using the `DbApiHook`, which is partly why we went ahead and change this attribute when we sub-classed `PostgresHook`.
   
   Anything else you all would need to see to make this change?
   
   Thanks for considering!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services