codeant-ai-for-open-source[bot] commented on code in PR #44736:
URL: https://github.com/apache/superset/pull/44736#discussion_r4129351982
##########
tests/unit_tests/db_engine_specs/test_doris.py:
##########
@@ -280,3 +280,77 @@ def test_get_catalog_names(
# Verify the returned catalog names
assert catalogs == expected_result
+
+
+def test_connection_form_default_driver_is_installed(mocker: MockerFixture) ->
None:
+ """
+ The database picker offers the connection form only when ``default_driver``
+ is among the drivers installed for the engine. pydoris registers a
+ ``MySQLDialect_mysqldb`` subclass named ``pydoris`` under both the
``doris``
+ and ``pydoris`` entry points, so its driver is ``mysqldb``.
+ """
+ from sqlalchemy.dialects.mysql.mysqldb import MySQLDialect_mysqldb
+
+ from superset.db_engine_specs import get_available_engine_specs
+ from superset.db_engine_specs.doris import DorisEngineSpec
+
+ class PyDorisDialect(MySQLDialect_mysqldb):
+ name = "pydoris"
+
+ def entry_point(name: str) -> Any:
+ ep = mocker.MagicMock()
+ ep.name = name
+ ep.value = "pydoris.sqlalchemy.dialect:DorisDialect"
+ ep.load.return_value = PyDorisDialect
+ return ep
+
+ mocker.patch(
+ "superset.db_engine_specs.load_engine_specs",
+ return_value=iter([DorisEngineSpec]),
+ )
+ mocker.patch(
+ "superset.db_engine_specs.entry_points",
+ side_effect=lambda group: (
+ [entry_point("doris"), entry_point("pydoris")]
+ if group == "sqlalchemy.dialects"
+ else []
+ ),
+ )
+
+ drivers = get_available_engine_specs()[DorisEngineSpec]
+
+ assert drivers == {"mysqldb"}
+ assert DorisEngineSpec.default_driver in drivers
+
+
[email protected]("encryption", [False, True])
+def test_build_sqlalchemy_uri_uses_the_doris_scheme(encryption: bool) -> None:
+ """
+ A URI built from the connection form must name a registered dialect:
+ ``pydoris+mysqldb`` (``engine+default_driver``) is not one, ``doris`` is.
+ """
+ from superset.db_engine_specs.base import BasicParametersType
+ from superset.db_engine_specs.doris import DorisEngineSpec
+
+ parameters: BasicParametersType = {
+ "username": "user",
+ "password": "p@ss",
+ "host": "doris.example.com",
+ "port": 9030,
+ "database": "internal.sales",
+ "query": {},
+ "encryption": encryption,
+ }
+
+ uri = DorisEngineSpec.build_sqlalchemy_uri(parameters)
+
+ url = make_url(uri)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `0b87d32`.
The test now calls `url.get_dialect()` and asserts it resolves to
`MySQLDialect_mysqldb`, verifying the emitted `doris` URI can resolve a
SQLAlchemy dialect.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]