arm-ka-fixtures/synthgen/tests/test_periods.py
Andrey Epifancev 418f066bd8 synthgen: периоды, внешние контрагенты, экономика компаний (#38)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 23:49:07 +04:00

24 lines
1012 B
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.

from datetime import date
from synthgen.periods import book_end, book_start, build_periods
def test_build_periods_simple():
ps = build_periods("2025-Q1", 4)
assert [p.key for p in ps] == ["2025-Q1", "2025-Q2", "2025-Q3", "2025-FY"]
assert [p.label_1c for p in ps] == ["1 квартал 2025 г.", "1 полугодие 2025 г.", "9 месяцев 2025 г.", "2025 г."]
assert all(p.start == date(2025, 1, 1) for p in ps)
assert [p.end for p in ps] == [date(2025, 3, 31), date(2025, 6, 30), date(2025, 9, 30), date(2025, 12, 31)]
def test_build_periods_rollover():
ps = build_periods("2025-Q3", 4)
assert [p.key for p in ps] == ["2025-Q3", "2025-FY", "2026-Q1", "2026-Q2"]
assert ps[2].start == date(2026, 1, 1) and ps[2].year == 2026 and ps[2].quarter == 1
assert book_end(ps) == date(2026, 6, 30)
def test_book_start():
assert book_start(build_periods("2025-Q1", 4)) == date(2024, 12, 31)
assert book_start(build_periods("2025-Q3", 4)) == date(2024, 12, 31)