Skip to content

Commit 401a83c

Browse files
committed
Apply PR Review fixes
1 parent 3dee53d commit 401a83c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

apps/blogs/migrations/0004_auto_20260222_0834.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
def rewrite_blog_urls(apps, schema_editor):
77
BlogEntry = apps.get_model("blogs", "BlogEntry")
8+
entries_to_update = []
89
for entry in BlogEntry.objects.filter(url__contains="pythoninsider.blogspot.com"):
910
entry.url = entry.url.replace("pythoninsider.blogspot.com", "blog.python.org")
10-
entry.save()
11+
entries_to_update.append(entry)
12+
if entries_to_update:
13+
BlogEntry.objects.bulk_update(entries_to_update, ['url'])
1114

1215

1316
class Migration(migrations.Migration):

apps/blogs/tests/test_parser.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ def test_rewrites_blogspot_url(self, mock_parse):
3131
mock_parse.return_value = {
3232
"entries": [
3333
{
34-
"title": "Test Title",
34+
"title": "Test Title HTTPS",
3535
"summary": "Summary",
36-
"published_parsed": (2026, 2, 22, 12, 0, 0, 0, 0, 0),
37-
"link": "https://pythoninsider.blogspot.com/2026/02/test.html",
36+
"published_parsed": (2024, 1, 15, 12, 0, 0, 0, 0, 0),
37+
"link": "https://pythoninsider.blogspot.com/2024/01/test.html",
38+
},
39+
{
40+
"title": "Test Title HTTP",
41+
"summary": "Summary",
42+
"published_parsed": (2024, 1, 15, 12, 0, 0, 0, 0, 0),
43+
"link": "http://pythoninsider.blogspot.com/2024/01/test2.html",
3844
}
3945
]
4046
}
4147
entries = get_all_entries("http://fake.url")
42-
self.assertEqual(len(entries), 1)
43-
self.assertEqual(entries[0]["url"], "https://blog.python.org/2026/02/test.html")
48+
self.assertEqual(len(entries), 2)
49+
self.assertEqual(entries[0]["url"], "https://blog.python.org/2024/01/test.html")
50+
self.assertEqual(entries[1]["url"], "http://blog.python.org/2024/01/test2.html")

0 commit comments

Comments
 (0)