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


##########
tests/unit_tests/db_engine_specs/test_bigquery.py:
##########
@@ -430,6 +430,72 @@ def test_get_default_catalog(mocker: MockerFixture) -> 
None:
     assert BigQueryEngineSpec.get_default_catalog(database) == "project"
 
 
[email protected](
+    ("sqlalchemy_uri", "expected_project"),
+    [
+        ("bigquery://uri-project", "uri-project"),
+        ("bigquery:///uri-project", "uri-project"),
+        ("bigquery://", None),
+    ],
+)
+def test_get_client_resolves_uri_project_with_service_account_credentials(
+    mocker: MockerFixture,
+    sqlalchemy_uri: str,
+    expected_project: str | None,
+) -> None:
+    """Test that service-account clients use the project from the engine 
URI."""
+    from superset.db_engine_specs.bigquery import BigQueryEngineSpec
+
+    credentials_info = {"project_id": "credential-project"}
+    credentials = mock.Mock()
+    engine = mock.MagicMock()
+    engine.url = make_url(sqlalchemy_uri)
+    engine.dialect.credentials_info = credentials_info
+    create_credentials = mocker.patch(
+        "superset.db_engine_specs.bigquery.service_account.Credentials."
+        "from_service_account_info",
+        return_value=credentials,
+    )
+    client = mocker.patch("superset.db_engine_specs.bigquery.bigquery.Client")
+
+    BigQueryEngineSpec._get_client(engine, mock.Mock())
+
+    create_credentials.assert_called_once_with(credentials_info)
+    client.assert_called_once_with(credentials=credentials, 
project=expected_project)
+
+
[email protected](
+    ("sqlalchemy_uri", "expected_project"),
+    [
+        ("bigquery://uri-project", "uri-project"),
+        ("bigquery:///uri-project", "uri-project"),
+        ("bigquery://", None),
+    ],
+)
+def test_get_client_resolves_uri_project_with_application_default_credentials(
+    mocker: MockerFixture,
+    sqlalchemy_uri: str,
+    expected_project: str | None,
+) -> None:
+    """Test that ADC clients use the project from the engine URI."""
+    from superset.db_engine_specs.bigquery import BigQueryEngineSpec
+
+    credentials = mock.Mock()
+    engine = mock.MagicMock()

Review Comment:
   **Suggestion:** Add type annotations to the newly added local variables in 
this test to comply with the rule requiring type hints where they can be 
provided. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   These newly added local variables are unannotated despite being 
straightforwardly type-hintable, so the code violates the rule requiring type 
hints for relevant variables.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![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=71886253b37f4ca6995c88e28fef457c&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=71886253b37f4ca6995c88e28fef457c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <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_bigquery.py
   **Line:** 483:484
   **Comment:**
        *Custom Rule: Add type annotations to the newly added local variables 
in this test to comply with the rule requiring type hints where they can be 
provided.
   
   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%2F41975&comment_hash=00d239b49d22f0c822e65368930ba467a3ea0d3766f4999b47304a0a82fb0e8f&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41975&comment_hash=00d239b49d22f0c822e65368930ba467a3ea0d3766f4999b47304a0a82fb0e8f&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