tmp/ 가 창끼리 안 건너가는 것이 확정돼(랩탑이 시간 두고 두 번 확인) 시험·예외가 저절로 건너가도록 git 안으로 옮김. 사용자 확정. - 내용은 하나도 안 고침 — 자리만 옮김. tmp/tests 는 남겨 둠. - 같은 이름이 이미 있던 64 개는 랩탑 것을 그대로 두고 건너뜀. - helper_b05_*.js 둘은 랩탑이 .cjs 로 이미 올린 것과 **줄바꿈만 다른 같은 내용**이라 복사본을 도로 뺌(시험이 .cjs 를 부름). - resources/tester/ 에서 전체 1176 통과 · 29 건너뜀 · 실패 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""초기 설계 실패 안내 메일 — 완료 메일 대신 나가는지, 문구에 관리자 문의가 있는지.
|
|
|
|
실제 SMTP는 타지 않는다. 확인 대상은 발송 여부 판정과 본문 규약이다.
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
|
|
import B03_FileInput.B03_FileInput_Email as email_mod
|
|
|
|
|
|
@pytest.fixture
|
|
def sent(monkeypatch):
|
|
captured = {}
|
|
|
|
async def _fake_send_email(*, to_email, subject, html):
|
|
captured["to"] = to_email
|
|
captured["subject"] = subject
|
|
captured["html"] = html
|
|
return True
|
|
|
|
monkeypatch.setattr(email_mod, "send_email", _fake_send_email)
|
|
return captured
|
|
|
|
|
|
def test_failed_email_carries_reason_and_admin_contact(sent, monkeypatch):
|
|
monkeypatch.setattr(email_mod, "ADMIN_EMAIL", "admin@example.com")
|
|
|
|
ok = asyncio.run(
|
|
email_mod.send_initial_design_failed_email(
|
|
project_id="325f57d9-0617-49b9-a793-983f24781e1e",
|
|
project_name="시제 프로젝트",
|
|
to_email="user@example.com",
|
|
reason="B06 초기 횡단 확정 실패 (status=404).",
|
|
)
|
|
)
|
|
|
|
assert ok is True
|
|
assert sent["to"] == "user@example.com"
|
|
assert "초기 설계 실패 알림" in sent["subject"]
|
|
assert "B06 초기 횡단 확정 실패 (status=404)." in sent["html"]
|
|
assert "관리자에게 문의" in sent["html"]
|
|
assert "admin@example.com" in sent["html"]
|
|
# 되돌릴 초기값이 없다는 사실을 본문에서 알려야 한다.
|
|
assert "초기값" in sent["html"]
|
|
|
|
|
|
def test_failed_email_without_admin_address_still_guides(sent, monkeypatch):
|
|
monkeypatch.setattr(email_mod, "ADMIN_EMAIL", "")
|
|
|
|
asyncio.run(
|
|
email_mod.send_initial_design_failed_email(
|
|
project_id="p1",
|
|
project_name="주소 없는 환경",
|
|
to_email="user@example.com",
|
|
reason="계획노선 CSV가 없어 초기 노선을 세울 수 없습니다.",
|
|
)
|
|
)
|
|
|
|
assert "관리자에게 문의" in sent["html"]
|
|
assert "mailto:" not in sent["html"]
|