fix(task-020): support s3 assets in publishing dry-run and commit
This commit is contained in:
@@ -135,6 +135,20 @@ class PublishingGitFlowPublicApiTest(unittest.TestCase):
|
||||
self.assertEqual(409, commit_response.status_code, commit_response.text)
|
||||
self.assertIn("non-fast-forward", commit_response.text.lower())
|
||||
|
||||
def test_publishing_dry_run_supports_s3_asset_urls_with_object_keys(self) -> None:
|
||||
article_id, _ = self._prepare_final_approved_article()
|
||||
self._rewrite_asset_urls_to_s3(article_id)
|
||||
|
||||
dry_run_response = self.client.post(
|
||||
f"/api/articles/{article_id}/publishing/dry-run",
|
||||
headers={DEMO_USER_EMAIL_HEADER: DEMO_EDITOR_EMAIL},
|
||||
)
|
||||
self.assertEqual(201, dry_run_response.status_code, dry_run_response.text)
|
||||
body = dry_run_response.json()
|
||||
self.assertTrue(body["content_shape_valid"])
|
||||
self.assertEqual("PUBLISH_COMMIT_READY", body["article"]["status"])
|
||||
self.assertEqual("PUBLISH_COMMIT_READY", body["article"]["publishing_status"])
|
||||
|
||||
def test_status_and_commits_endpoints_expose_required_metadata(self) -> None:
|
||||
article_id, _ = self._prepare_final_approved_article()
|
||||
|
||||
@@ -202,6 +216,27 @@ class PublishingGitFlowPublicApiTest(unittest.TestCase):
|
||||
self._run_git(["remote", "add", "origin", str(self.bare_repo_path)], cwd=self.seed_repo_path)
|
||||
self._run_git(["push", "origin", "main"], cwd=self.seed_repo_path)
|
||||
|
||||
def _rewrite_asset_urls_to_s3(self, article_id: str) -> None:
|
||||
assets = self.repository.assets.list_for_article(UUID(article_id))
|
||||
now = self.repository.articles.get(UUID(article_id)).updated_at
|
||||
for asset in assets:
|
||||
if asset.status.value != "APPROVED":
|
||||
continue
|
||||
self.assertTrue(asset.object_key)
|
||||
self.repository.assets.update(
|
||||
article_id=UUID(article_id),
|
||||
asset_id=asset.id,
|
||||
section_id=asset.section_id,
|
||||
title=asset.title,
|
||||
prompt=asset.prompt,
|
||||
object_key=asset.object_key,
|
||||
file_url=f"s3://pipeline-local/{asset.object_key}",
|
||||
alt_text=asset.alt_text,
|
||||
caption=asset.caption,
|
||||
status=asset.status,
|
||||
updated_at=now,
|
||||
)
|
||||
|
||||
def _run_git(self, args: list[str], *, cwd: Path | None = None) -> None:
|
||||
subprocess.run(
|
||||
["git", *args],
|
||||
|
||||
Reference in New Issue
Block a user