|
1 | | -import time |
| 1 | +from datetime import datetime |
2 | 2 | from unittest.mock import MagicMock |
3 | 3 | import pytest |
4 | 4 |
|
| 5 | +from notifier import timing |
5 | 6 | from notifier.database.drivers.base import BaseDatabaseDriver |
6 | 7 | from notifier.database.drivers.mysql import MySqlDriver |
7 | 8 | from notifier.database.utils import resolve_driver_from_config |
@@ -30,7 +31,9 @@ def deletions_test_database( |
30 | 31 | password=notifier_auth["mysql_password"], |
31 | 32 | ) |
32 | 33 | db.scrub_database() |
33 | | - now = int(time.time()) |
| 34 | + # Use the same hour-rounded 'now' as the production code |
| 35 | + now_hour = timing.now.replace(minute=0, second=0, microsecond=0) |
| 36 | + now = int(datetime.timestamp(now_hour)) |
34 | 37 | # Add a wiki, thread, and parent post context |
35 | 38 | db.store_supported_wikis( |
36 | 39 | [{"id": "test-wiki", "name": "Test Wiki", "secure": 1}] |
@@ -76,7 +79,7 @@ def deletions_test_database( |
76 | 79 | # Should be selected (5-6 hour window) |
77 | 80 | { |
78 | 81 | "post_id": "p-2", |
79 | | - "posted_timestamp": now - 5 * 3600 - 1800, # 5.5 hours ago |
| 82 | + "posted_timestamp": now - (5 * 3600) - 1800, # 5.5 hours ago |
80 | 83 | "post_title": "Should Check 2", |
81 | 84 | "post_snippet": "", |
82 | 85 | "author_user_id": "user1", |
|
0 commit comments