--
This commit is contained in:
@@ -11,6 +11,7 @@ from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
|
||||
from app.common.enums import ReportType
|
||||
from app.common.exceptions import ValidationError
|
||||
from app.reports import service as svc
|
||||
|
||||
@@ -36,7 +37,7 @@ def _service() -> svc.DCRService:
|
||||
|
||||
|
||||
def _report(day: date) -> SimpleNamespace:
|
||||
return SimpleNamespace(report_date=day)
|
||||
return SimpleNamespace(report_date=day, report_type=ReportType.ACTUAL)
|
||||
|
||||
|
||||
class TestVisitTime:
|
||||
@@ -57,12 +58,19 @@ class TestVisitTime:
|
||||
class TestReportDate:
|
||||
def test_today_is_todays_ist_date_just_after_midnight(self, at):
|
||||
at(2026, 9, 21, 1, 0) # still 20 Sep in UTC
|
||||
_service()._validate_report_date(date(2026, 9, 21))
|
||||
_service()._validate_report_date(date(2026, 9, 21), ReportType.ACTUAL)
|
||||
|
||||
def test_tomorrow_is_rejected(self, at):
|
||||
def test_tomorrow_is_rejected_for_a_done_or_self_report(self, at):
|
||||
at(2026, 9, 21, 1, 0)
|
||||
for report_type in (ReportType.ACTUAL, ReportType.SELF):
|
||||
with pytest.raises(ValidationError):
|
||||
_service()._validate_report_date(date(2026, 9, 22), report_type)
|
||||
|
||||
def test_a_plan_may_be_made_up_to_two_days_ahead(self, at):
|
||||
at(2026, 9, 21, 1, 0)
|
||||
_service()._validate_report_date(date(2026, 9, 23), ReportType.PLAN)
|
||||
with pytest.raises(ValidationError):
|
||||
_service()._validate_report_date(date(2026, 9, 22))
|
||||
_service()._validate_report_date(date(2026, 9, 24), ReportType.PLAN)
|
||||
|
||||
|
||||
def test_local_helpers_use_the_configured_timezone():
|
||||
|
||||
Reference in New Issue
Block a user