Files
dbx-main/app/modules/performance/tests/test_formula.py
T
king f79b970056 feat(performance): 앞날 입력·계산식 칸·기간 합계 맨 위
- 매출 수동 입력·광고비 날짜 칸과 엑셀·광고 보고서 업로드에서 오늘 이후 날짜 허용
- 이번달 등 일자별 표의 기간 합계 행을 제목 행 바로 아래로
- 날짜 칸에 = 없이 1000+2000 계산식 입력(formula.parse_amount), 식은
  마이그레이션 008 formula 열에 저장해 파랑 굵은 숫자·다시 누르면 식
- 광고비 탭 직접 입력값은 굵게 해제(굵게는 계산식만)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 11:30:11 +09:00

29 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""날짜 칸 계산식(formula.parse_amount) — = 없이 1000+2000 을 바로 계산(2026-10-21)."""
from __future__ import annotations
import pytest
from app.modules.performance.formula import FormulaError, parse_amount
@pytest.mark.parametrize("raw, expected", [
("", (None, None)), (None, (None, None)), (" ", (None, None)),
("12,000", (12000, None)), (87000, (87000, None)), ("-5000", (-5000, None)), ("1,234원", (1234, None)),
("1000+2000", (3000, "1000+2000")),
("1,000 + 2,000 * 2", (5000, "1000+2000*2")),
("(10000+5000)×2", (30000, "(10000+5000)*2")),
("10000÷3", (3333, "10000/3")),
("10001/2", (5001, "10001/2")), # 반올림
("=500-200", (300, "500-200")), # 엑셀 버릇 = 도 됨
("-100+50", (-50, "-100+50")),
("1.5*1000", (1500, "1.5*1000")),
])
def test_parse_amount(raw, expected):
assert parse_amount(raw) == expected
@pytest.mark.parametrize("raw", ["abc", "1000+", "*5", "(1+2", "1+2)", "5/0", "1e5", "1000+2000a", "1" * 201])
def test_parse_amount_errors(raw):
with pytest.raises(FormulaError):
parse_amount(raw)