상시 프리렌더와 중복 예약 안내를 없애고, 검수된 발행 버전을 보존한다. 미리보기는 실제 렌더 완료까지 스피너를 표시한다. 사이트 81건, 발행·롤백·서치콘솔 45건, 프로세스 수명 3건 통과. 빌더·사이트 빌드 및 compose 설정 검증 통과.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import asyncio
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
from services import render_service
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def fake_renderer(monkeypatch, tmp_path):
|
|
# 이 파일은 conftest의 렌더 대역 대신 실제 자식 프로세스 수명만 검사한다.
|
|
monkeypatch.setenv("SITE_OUTPUT_DIR", str(tmp_path))
|
|
|
|
|
|
async def test_process_success():
|
|
code, _ = await render_service._run_subprocess([sys.executable, "-c", "print(1)"], 2)
|
|
assert code == 0
|
|
|
|
|
|
async def test_timeout_releases_lock():
|
|
code, _ = await render_service._run_subprocess(
|
|
[sys.executable, "-c", "import time;time.sleep(5)"], 0.1
|
|
)
|
|
assert code is None
|
|
code, _ = await render_service._run_subprocess([sys.executable, "-c", "print(1)"], 2)
|
|
assert code == 0
|
|
|
|
|
|
async def test_cancel_releases_lock():
|
|
task = asyncio.create_task(render_service._run_subprocess(
|
|
[sys.executable, "-c", "import time;time.sleep(5)"], 10
|
|
))
|
|
await asyncio.sleep(0.1)
|
|
task.cancel()
|
|
with pytest.raises(asyncio.CancelledError):
|
|
await task
|
|
code, _ = await render_service._run_subprocess([sys.executable, "-c", "print(1)"], 2)
|
|
assert code == 0
|