fix: convert feed timestamps to US/Eastern and add test

Made-with: Cursor
This commit is contained in:
cottongin
2026-04-06 21:39:00 -04:00
parent f7b424b692
commit e40023b9f9
2 changed files with 20 additions and 0 deletions

View File

@@ -81,3 +81,19 @@ def test_fetch_handles_feed_error(app, db):
assert result["error"] is not None
assert Article.query.count() == 0
def test_fetch_converts_timezone_to_eastern(app, db):
with app.app_context():
with patch("src.fetcher.requests.get") as mock_get:
mock_get.return_value = _mock_feed_response(SAMPLE_RSS_XML)
with patch("src.fetcher.process_image") as mock_img:
mock_img.return_value = ("/fake/path.jpg", 800, 450)
fetch_and_cache_articles()
article = Article.query.filter_by(title="Test Article One").first()
# The XML has: Mon, 06 Apr 2026 12:00:00 +0000
# US/Eastern in April is EDT (UTC-4), so it should be 08:00:00
assert article.pub_date.tzinfo is None
assert article.pub_date.hour == 8
assert article.pub_date.minute == 0