guan404ming commented on code in PR #48706:
URL: https://github.com/apache/airflow/pull/48706#discussion_r2026156997


##########
providers/mysql/tests/unit/mysql/hooks/test_mysql.py:
##########
@@ -93,6 +93,35 @@ def test_get_uri(self, mock_connect):
         args, kwargs = mock_connect.call_args
         assert self.db_hook.get_uri() == 
"mysql://login:password@host/schema?charset=utf-8"
 
+        self.connection.login = "user@domain"
+        self.connection.password = "pass/word!"
+        assert self.db_hook.get_uri() == 
"mysql://user%40domain:pass%2Fword%21@host/schema?charset=utf-8"
+
+        # Test with mysql-connector-python client
+        self.connection.login = "user@domain"
+        self.connection.password = "password"
+        self.connection.extra = json.dumps({"client": 
"mysql-connector-python"})
+        assert self.db_hook.get_uri() == 
"mysql+mysqlconnector://user%40domain:password@host/schema"
+
+        self.connection.port = 3307
+        assert self.db_hook.get_uri() == 
"mysql+mysqlconnector://user%40domain:password@host:3307/schema"
+
+        self.connection.schema = "db/name"
+        assert self.db_hook.get_uri() == 
"mysql+mysqlconnector://user%40domain:password@host:3307/db%2Fname"
+
+        self.connection.schema = "schema"
+        self.connection.extra = json.dumps(
+            {
+                "client": "mysql-connector-python",
+                "ssl_ca": "/path/to/ca",
+                "ssl_cert": "/path/to/cert with space",
+            }
+        )
+        assert (
+            self.db_hook.get_uri()
+            == 
"mysql+mysqlconnector://user%40domain:password@host:3307/schema?ssl_ca=%2Fpath%2Fto%2Fca&ssl_cert=%2Fpath%2Fto%2Fcert+with+space"
+        )
+

Review Comment:
   That would be much better, thanks~



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