justinpakzad commented on code in PR #68783:
URL: https://github.com/apache/airflow/pull/68783#discussion_r3447517487
##########
airflow-core/tests/unit/core/test_settings.py:
##########
@@ -500,3 +500,58 @@ def test_early_return_when_all_none(self):
settings.dispose_orm(do_log=False)
mock_close.assert_not_called()
+
+
+class TestGetAsyncConnUriFromSync:
+ """Tests for _get_async_conn_uri_from_sync function."""
+
+ def test_sqlite_uri_conversion(self):
+ """Test conversion of SQLite sync URI to async with aiosqlite."""
+ result =
settings._get_async_conn_uri_from_sync("sqlite:///path/to/db.sqlite")
+ assert result == "sqlite+aiosqlite:///path/to/db.sqlite"
+
+ def test_postgresql_uri_conversion(self):
+ """Test conversion of PostgreSQL sync URI to async with asyncpg."""
+ result =
settings._get_async_conn_uri_from_sync("postgresql://user:pass@localhost/dbname")
+ assert result == "postgresql+asyncpg://user:pass@localhost/dbname"
+
+ def test_mysql_uri_conversion(self):
+ """Test conversion of MySQL sync URI to async with aiomysql."""
+ result =
settings._get_async_conn_uri_from_sync("mysql://user:pass@localhost/dbname")
+ assert result == "mysql+aiomysql://user:pass@localhost/dbname"
+
+ def test_postgresql_psycopg2_uri_conversion(self):
+ """Test conversion of PostgreSQL with psycopg2 driver to asyncpg."""
+ result =
settings._get_async_conn_uri_from_sync("postgresql+psycopg2://user@localhost/db")
+ assert result == "postgresql+asyncpg://user@localhost/db"
Review Comment:
Would it maybe make sense to parameterize these tests? It could be tightened
up to something like:
````
@pytest.mark.parametrize(
("sync_uri", expected"),
[
("sqlite:///path/to/db.sqlite",
"sqlite+aiosqlite:///path/to/db.sqlite"),
("postgresql://user:pass@localhost/dbname",
"postgresql+asyncpg://user:pass@localhost/dbname"),
("mysql://user:pass@localhost/dbname",
"mysql+aiomysql://user:pass@localhost/dbname"),
("postgresql+psycopg2://user@localhost/db",
"postgresql+asyncpg://user@localhost/db"),
],
)
def test_supported_scheme_conversion(self, sync_uri, expected):
assert settings._get_async_conn_uri_from_sync(sync_uri) == expected
--
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]