Lee-W commented on code in PR #74448:
URL: https://github.com/apache/airflow/pull/74448#discussion_r4227301279
##########
providers/common/ai/tests/unit/common/ai/toolsets/test_sql.py:
##########
@@ -548,6 +548,42 @@ def
test_a_row_carrying_the_connection_password_reaches_the_model_masked(self, r
class TestSQLToolsetCheckQuery:
+ @pytest.mark.parametrize(
+ ("allow_writes", "expected_valid"),
+ [(False, False), (True, True)],
+ )
+ def test_write_statement_validity_follows_allow_writes(self, allow_writes,
expected_valid):
+ ts = SQLToolset("pg_default", allow_writes=allow_writes)
+ ts._hook = _make_mock_db_hook()
+
+ result = asyncio.run(
+ ts.call_tool(
+ "check_query",
+ {"sql": "INSERT INTO users VALUES (3, 'Eve')"},
+ ctx=MagicMock(),
+ tool=MagicMock(),
+ )
+ )
+ assert json.loads(result)["valid"] is expected_valid
+
+ @pytest.mark.parametrize(
+ ("table", "expected_valid"),
+ [("orders", True), ("secret_salaries", False)],
Review Comment:
Split the parametrized test. The `secret_salaries` case now asserts
`"secret_salaries" in data["error"]`; the `orders` case only asserts `valid is
True`.
--
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]