iamtodor opened a new issue, #39475:
URL: https://github.com/apache/airflow/issues/39475

   ### What do you see as an issue?
   
   Per paragraph 
https://airflow.apache.org/docs/apache-airflow/2.8.2/best-practices.html#mocking-variables-and-connections
   The given example
   
   ```
   conn = Connection(
       conn_type="gcpssh",
       login="cat",
       host="conn-host",
   )
   conn_uri = conn.get_uri()
   with mock.patch.dict("os.environ", AIRFLOW_CONN_MY_CONN=conn_uri):
       assert "cat" == Connection.get("my_conn").login
   ```
   
   raises an error:
   
   ```
   def test_foo():
           conn = Connection(
               conn_type="gcpssh",
               login="cat",
               host="conn-host",
           )
           conn_uri = conn.get_uri()
           with mock.patch.dict("os.environ", AIRFLOW_CONN_MY_CONN=conn_uri):
   >           assert "cat" == Connection.get("my_conn").login
   E           AttributeError: type object 'Connection' has no attribute 'get'
   
   path/to/test/file.py:12: AttributeError
   ```
   
   ### Solving the problem
   
   Update the doc
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to