codeant-ai-for-open-source[bot] commented on code in PR #41624:
URL: https://github.com/apache/superset/pull/41624#discussion_r3507625894
##########
tests/integration_tests/queries/saved_queries/api_tests.py:
##########
@@ -677,6 +677,69 @@ def test_create_saved_query(self):
db.session.delete(model)
db.session.commit()
+ def test_create_saved_query_blank_label(self):
+ """
+ Saved Query API: Test create rejects blank/whitespace-only labels
+ """
+ example_db = get_example_database()
+ self.login(ADMIN_USERNAME)
+ uri = "api/v1/saved_query/"
+
+ for label in ("", " ", "\t\n"):
+ post_data = {
+ "schema": "schema1",
+ "label": label,
+ "description": "some description",
+ "sql": "SELECT col1, col2 from table1",
+ "db_id": example_db.id,
+ }
+ rv = self.client.post(uri, json=post_data)
+ data = json.loads(rv.data.decode("utf-8"))
+ assert rv.status_code == 422
+ assert "label" in data["message"]
+
+ def test_create_saved_query_strips_label(self):
Review Comment:
**Suggestion:** Add a return type hint to this new test method signature
(for example `-> None`) to comply with the mandatory type-hint rule.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This added test method has no explicit return type hint. That directly
matches the type-hint requirement for new or modified Python methods.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ff4992083f894319bd415c8adec8a9fc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ff4992083f894319bd415c8adec8a9fc&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/integration_tests/queries/saved_queries/api_tests.py
**Line:** 701:701
**Comment:**
*Custom Rule: Add a return type hint to this new test method signature
(for example `-> None`) to comply with the mandatory type-hint rule.
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%2F41624&comment_hash=e56f913de797cd093eb381bcfe1f93349efc04b5aceee28af49c144c20d5952d&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41624&comment_hash=e56f913de797cd093eb381bcfe1f93349efc04b5aceee28af49c144c20d5952d&reaction=dislike'>👎</a>
##########
tests/integration_tests/queries/saved_queries/api_tests.py:
##########
@@ -677,6 +677,69 @@ def test_create_saved_query(self):
db.session.delete(model)
db.session.commit()
+ def test_create_saved_query_blank_label(self):
+ """
+ Saved Query API: Test create rejects blank/whitespace-only labels
+ """
+ example_db = get_example_database()
+ self.login(ADMIN_USERNAME)
+ uri = "api/v1/saved_query/"
+
+ for label in ("", " ", "\t\n"):
+ post_data = {
+ "schema": "schema1",
+ "label": label,
+ "description": "some description",
+ "sql": "SELECT col1, col2 from table1",
+ "db_id": example_db.id,
+ }
+ rv = self.client.post(uri, json=post_data)
+ data = json.loads(rv.data.decode("utf-8"))
+ assert rv.status_code == 422
+ assert "label" in data["message"]
+
+ def test_create_saved_query_strips_label(self):
+ """
+ Saved Query API: Test create trims surrounding whitespace from labels
+ """
+ example_db = get_example_database()
+ self.login(ADMIN_USERNAME)
+ uri = "api/v1/saved_query/"
+
+ post_data = {
+ "schema": "schema1",
+ "label": " label1 ",
+ "description": "some description",
+ "sql": "SELECT col1, col2 from table1",
+ "db_id": example_db.id,
+ }
+ rv = self.client.post(uri, json=post_data)
+ data = json.loads(rv.data.decode("utf-8"))
+ assert rv.status_code == 201
+
+ model = db.session.query(SavedQuery).get(data.get("id"))
+ assert model.label == "label1"
+
+ # Rollback changes
+ db.session.delete(model)
+ db.session.commit()
+
+ @pytest.mark.usefixtures("create_saved_queries")
+ def test_update_saved_query_blank_label(self):
Review Comment:
**Suggestion:** Add a return type hint to this newly introduced test method
signature (for example `-> None`) to meet the type-hint policy. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is another newly introduced Python test method lacking a return type
hint, so it violates the stated type-hint rule.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=747fbf2239cf4f228a4875d156413359&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=747fbf2239cf4f228a4875d156413359&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/integration_tests/queries/saved_queries/api_tests.py
**Line:** 728:728
**Comment:**
*Custom Rule: Add a return type hint to this newly introduced test
method signature (for example `-> None`) to meet the type-hint policy.
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%2F41624&comment_hash=fb1fb0be001a092354c78f27f14c9fdb7d8b6f3d7e2b279234a45796e0006b55&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41624&comment_hash=fb1fb0be001a092354c78f27f14c9fdb7d8b6f3d7e2b279234a45796e0006b55&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]