bito-code-review[bot] commented on PR #40693:
URL: https://github.com/apache/superset/pull/40693#issuecomment-4608795370
<!-- Bito Reply -->
The current test assertion `assert
notification.now.strftime(datetime_pattern) in subject` is correct because it
compares the subject against the specific timestamp instance
(`notification.now`) that the `EmailNotification` object used to generate that
subject. This ensures the test is deterministic and avoids flakiness if the
test execution crosses a midnight boundary, as the subject and the assertion
are both derived from the same `notification.now` value. To make the test more
robust against a revert, you could mock `datetime.now` to return a fixed, known
timestamp, ensuring the subject contains that specific date regardless of when
the test runs.
**tests/unit_tests/reports/notifications/email_tests.py**
```
# Mocking datetime to ensure a fixed, predictable timestamp
with patch("superset.reports.notifications.email.datetime") as
mock_datetime:
mock_datetime.now.return_value = datetime(2026, 1, 1,
tzinfo=timezone("UTC"))
notification = EmailNotification(
recipient=ReportRecipients(type=ReportRecipientType.EMAIL),
content=content
)
subject = notification._get_subject()
assert "2026-01-01" in subject
```
--
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]