bito-code-review[bot] commented on code in PR #44704:
URL: https://github.com/apache/superset/pull/44704#discussion_r4113367393


##########
tests/unit_tests/db_engine_specs/test_oracle.py:
##########
@@ -128,3 +128,50 @@ def test_denormalize_name(name: str, expected_result: str):
     from superset.db_engine_specs.oracle import OracleEngineSpec as spec  # 
noqa: N813
 
     assert spec.denormalize_name(oracle.dialect(), name) == expected_result
+
+
+def test_get_cancel_query_id() -> None:
+    from superset.db_engine_specs.oracle import OracleEngineSpec
+    from superset.models.sql_lab import Query
+
+    cursor = mock.Mock()
+    cursor.fetchone.return_value = (162, 53643, 1)
+    assert OracleEngineSpec.get_cancel_query_id(cursor, Query()) == 
"162,53643,1"

Review Comment:
   <!-- Bito Reply -->
   The suggestion to use `mock.Mock()` instead of `Query()` is appropriate. As 
noted in the review, `superset.models.sql_lab.Query` is a SQLAlchemy model that 
expects a `session` argument during initialization. Instantiating it without 
one will raise a `TypeError`, causing the test to fail before it can execute 
the assertion. Using a mock object is a standard and safe practice for unit 
tests where the specific model instance logic is not being tested.
   
   **tests/unit_tests/db_engine_specs/test_oracle.py**
   ```
   cursor = mock.Mock()
       cursor.fetchone.return_value = (162, 53643, 1)
       assert OracleEngineSpec.get_cancel_query_id(cursor, mock.Mock()) == 
"162,53643,1"
   ```



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