chore(pm): vendor the Aramesh/PM platform under pm/ (squash of Aramesh/PM @ 91f3271)
The PM panel (PmPanelPage -> iframe /pm/) needs the project-management platform served at /pm/ on the ERP domain. Source: org repo Aramesh/PM, branch feature/project-management-platform. Update via: git subtree pull --prefix=pm aramesh-pm feature/project-management-platform --squash
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""Unit tests for unified DateService."""
|
||||
from datetime import date
|
||||
import pytest
|
||||
|
||||
from app.utils.date_service import date_service
|
||||
|
||||
|
||||
def test_date_service_parse_iso():
|
||||
d = date_service.parse("2026-09-16")
|
||||
assert d == date(2026, 9, 16)
|
||||
|
||||
|
||||
def test_date_service_parse_jalali():
|
||||
# 1405/06/25 -> 2026-09-16
|
||||
d = date_service.parse("1405/06/25")
|
||||
assert d == date(2026, 9, 16)
|
||||
|
||||
|
||||
def test_date_service_to_jalali():
|
||||
d = date(2026, 9, 16)
|
||||
assert date_service.to_jalali(d) == "1405/06/25"
|
||||
|
||||
|
||||
def test_date_service_duration_calculation():
|
||||
d1 = date(2026, 9, 10)
|
||||
d2 = date(2026, 9, 15)
|
||||
# gap between the dates: the end date is not counted
|
||||
assert date_service.calculate_duration(d1, d2) == 5
|
||||
assert date_service.calculate_duration(d1, d1) == 0
|
||||
assert date_service.calculate_duration(None, d2) == 0
|
||||
# inverted range is not a duration
|
||||
assert date_service.calculate_duration(d2, d1) == 0
|
||||
|
||||
|
||||
def test_date_service_compute_end_date():
|
||||
d1 = date(2026, 9, 10)
|
||||
# 0 days means start and end are the same day
|
||||
assert date_service.compute_end_date(d1, 0) == d1
|
||||
# 5 days is the gap, so the end date is 5 days later
|
||||
assert date_service.compute_end_date(d1, 5) == date(2026, 9, 15)
|
||||
|
||||
|
||||
def test_duration_and_end_date_are_inverses():
|
||||
"""The pair must round-trip, otherwise saved values drift on reload."""
|
||||
d1 = date(2026, 9, 10)
|
||||
for gap in (0, 1, 4, 5, 30):
|
||||
end = date_service.compute_end_date(d1, gap)
|
||||
assert date_service.calculate_duration(d1, end) == gap
|
||||
Reference in New Issue
Block a user