Add unit test for PostgresHook with invalid connection id#61235
Add unit test for PostgresHook with invalid connection id#61235KL-2300032590 wants to merge 2 commits intoapache:mainfrom
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
|
||
| def test_postgres_hook_invalid_conn_id(): | ||
| with pytest.raises(Exception): | ||
| PostgresHook(postgres_conn_id=None) |
There was a problem hiding this comment.
You could also pass Airflow specific exceptions .
I believe something wrong here with - indentation ?
There was a problem hiding this comment.
Yes,i will fix it and point on the exception type — I’ll update the test to assert an Airflow-specific exception (AirflowException) instead of the generic Exception..&
I’ll push the exception fix shortly and update the PR.
Appreciate the guidance!
|
@KL-2300032590 Thanks !! The defaults properties are defined here- You can easily run these tests locally - unit -tests- docs You could also run static checks locally - using |
KL-2300032590
left a comment
There was a problem hiding this comment.
I’ve updated the test to use an Airflow-specific exception (AirflowConfigException) and verified the indentation.
Please let me know if this looks good now.
This test looks a bit weird to me, I would expect this be a general behaviour, not only for PostgresHook? |
|
Sounds like not really consequential AI generated test. |
|
I tested this - |
This pull request adds a unit test to ensure that
PostgresHookfails fastwhen initialized with an invalid
postgres_conn_id.The test improves defensive coverage for the Postgres provider by validating
error handling for incorrect hook configuration.
Note: Tests could not be executed locally due to missing Airflow pytest plugins.
Relying on CI for validation.
Was generative AI tooling used to co-author this PR?
Generated-by: ChatGPT following the Apache Airflow guidelines