Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8
context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; }
name:ph… (push) Successful in 48s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18
POSTGIS_VERSION=3
VCHORD_VERSION=0.5.3
context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 55s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3
context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 54s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim
context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:linkki-tiedotus oci_labels:… (push) Successful in 39s
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
import asyncio
|
|
from datetime import datetime, timedelta
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from webapp import app as app_module
|
|
|
|
|
|
def test_startup_recovery_runs_overdue_scheduled_posts_without_waiting_for_retry() -> None:
|
|
now = datetime.now().astimezone()
|
|
item = {
|
|
"status": "scheduled",
|
|
"scheduled_for": (now - timedelta(minutes=5)).isoformat(),
|
|
"scheduled_next_attempt_at": (now + timedelta(minutes=30)).isoformat(),
|
|
}
|
|
|
|
assert app_module.is_scheduled_publish_due(item, recover_missed_jobs=True) is True
|
|
assert app_module.is_scheduled_publish_due(item, recover_missed_jobs=False) is False
|
|
|
|
|
|
def test_manual_publish_retries_once_after_a_failed_attempt(monkeypatch) -> None:
|
|
app = FastAPI()
|
|
directory_name = "retry-once"
|
|
app.state.operations = {
|
|
directory_name: {
|
|
"running": True,
|
|
"completed": False,
|
|
"output": "",
|
|
"result": None,
|
|
"error": None,
|
|
}
|
|
}
|
|
app.state.operation_tasks = {directory_name: object()}
|
|
app.state.scheduler_lock = asyncio.Lock()
|
|
attempts = []
|
|
|
|
async def fake_run_publish_action(post_dir: Path, config, progress):
|
|
attempts.append(post_dir)
|
|
return {"status": "failed", "output": "still unavailable"}
|
|
|
|
monkeypatch.setattr(app_module, "run_publish_action_with_progress", fake_run_publish_action)
|
|
|
|
asyncio.run(app_module.run_publish_operation(app, directory_name, Path("/tmp/retry-once"), None))
|
|
|
|
assert attempts == [Path("/tmp/retry-once"), Path("/tmp/retry-once")]
|
|
operation = app.state.operations[directory_name]
|
|
assert operation["completed"] is True
|
|
assert operation["result"] == "failed"
|
|
assert directory_name not in app.state.operation_tasks
|