codeant-ai-for-open-source[bot] commented on code in PR #44736:
URL: https://github.com/apache/superset/pull/44736#discussion_r4119093940


##########
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:
   **Suggestion:** Parsing with `make_url` does not resolve the dialect, so 
this test passes even when the emitted `doris` URI cannot create a SQLAlchemy 
engine.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often` ยท ๐Ÿท๏ธ `Api mismatch`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e041a82ebaae4535a338a9ff11cca86a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e041a82ebaae4535a338a9ff11cca86a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/db_engine_specs/test_doris.py
   **Line:** 347:347
   **Comment:**
        *Api Mismatch: Parsing with `make_url` does not resolve the dialect, so 
this test passes even when the emitted `doris` URI cannot create a SQLAlchemy 
engine.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44736&comment_hash=a18ccea38230e2433ada837fc369fecafd6881c7865693f82d962448fc5c416b&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44736&comment_hash=a18ccea38230e2433ada837fc369fecafd6881c7865693f82d962448fc5c416b&reaction=dislike'>๐Ÿ‘Ž</a>



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

Reply via email to