errands
small jobs the runtime does for the studio.
git clone https://owenrusk.dev/errands.git
commit bf7c85c1acf32e9a288ab56608b259d359bfb301 parent 2cbf7d78b8c80f8dfb26b428750c88975032b1f7 author Owen Rusk <owen@papermothgames.com> date 2026-04-21 13:30:09 -0500
posts: publish once for a batch, not once a post
| errands/posts.py | +2 | -1 |
| tests/test_posts.py | +7 | -0 |
diff --git a/errands/posts.py b/errands/posts.py index 03e5b6d..448542d 100644 --- a/errands/posts.py +++ b/errands/posts.py @@ -44,6 +44,7 @@ def publish_due(now: datetime | None = None, site: Path | None = None, run=subpr published = [] for path in due(now, site): path.rename(site / "posts" / path.name)- run(shlex.split(settings.SITE_PUBLISH), cwd=site, check=True)published.append(path.stem) + if published: + run(shlex.split(settings.SITE_PUBLISH), cwd=site, check=True) return published diff --git a/tests/test_posts.py b/tests/test_posts.py index 1b338ee..c20ca3f 100644 --- a/tests/test_posts.py +++ b/tests/test_posts.py @@ -38,6 +38,13 @@ class PublishTest(unittest.TestCase): self.assertTrue((self.site / "scheduled" / "later-post.md").exists()) self.assertEqual(self.runs, [["make", "publish"]]) + def test_one_publish_for_two_posts(self): + post(self.site, "test-post", "2024-11-20T09:00:00-06:00") + post(self.site, "other-post", "2024-11-20T09:00:00-06:00") + now = datetime(2024, 11, 21, 12, 0, tzinfo=CENTRAL) + self.assertEqual(posts.publish_due(now, self.site, self.record), ["other-post", "test-post"]) + self.assertEqual(len(self.runs), 1) + def test_date_without_a_zone(self): post(self.site, "test-post", "2024-11-20T09:00:00") now = datetime(2024, 11, 21, 12, 0, tzinfo=CENTRAL)