"""날짜 칸 계산식(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)