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


##########
tests/unit_tests/reports/dao_test.py:
##########
@@ -89,3 +89,42 @@ def 
test_find_last_error_notification_returns_log_when_only_errors(
 
     result = ReportScheduleDAO.find_last_error_notification(schedule)
     assert result is error_log
+
+
+@patch("superset.daos.report.ReportSchedule")
+@patch("superset.daos.report.db")
+def test_find_by_extra_metadata_escapes_like_wildcards(
+    mock_db: MagicMock, mock_report_schedule: MagicMock
+) -> None:
+    """LIKE wildcards in the slug must be escaped so they match literally."""
+    from superset.daos.report import ReportScheduleDAO
+
+    expected: list[MagicMock] = [MagicMock()]
+    mock_db.session.query.return_value.filter.return_value.all.return_value = 
expected
+
+    result = ReportScheduleDAO.find_by_extra_metadata("100%_off")
+
+    assert result is expected
+    # autoescape=True is what neutralises the LIKE wildcards in the slug
+    mock_report_schedule.extra_json.contains.assert_called_once_with(
+        "100%_off", autoescape=True
+    )

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>SEMANTIC_DUPLICATION: Duplicate test coverage</b></div>
   <div id="fix">
   
   This test duplicates existing integration tests in 
`tests/unit_tests/daos/test_report_dao.py` (lines 71-92) that verify the same 
LIKE wildcard escaping behavior. Integration tests with real database sessions 
are superior because they verify actual query behavior, not just mock call 
arguments.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #27ed6d</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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