"""순환 문구 글 형식 — 사장님이 줄 단위로 고친 글이 그대로 계절·월·날씨 문구로 읽혀야 한다.""" from services import catchphrase_text def test_round_trips_every_kind(): items = [ {"text": "백 년 된 집에서 하룻밤", "kind": "general"}, {"text": "봄에는 대문을 열어 둡니다", "kind": "season", "season": "봄"}, {"text": "새해 첫 아침을 이 집에서", "kind": "month", "month": 1}, {"text": "기와에 빗소리가 납니다", "kind": "weather", "weather": "비"}, ] text = catchphrase_text.encode(items) assert text.splitlines() == [ "백 년 된 집에서 하룻밤", "봄 | 봄에는 대문을 열어 둡니다", "1월 | 새해 첫 아침을 이 집에서", "비 | 기와에 빗소리가 납니다", ] assert catchphrase_text.decode(text) == items def test_unknown_tag_stays_a_general_line(): assert catchphrase_text.decode("장마 | 비가 옵니다\n\n 13월 | 없는 달 ") == [ {"text": "장마 | 비가 옵니다", "kind": "general"}, {"text": "13월 | 없는 달", "kind": "general"}, ]