Skip to content

test_date_conversion

Test conversion of SG date fields to AYON datetime attributes.

SG date fields have no timezone and are returned as "YYYY-MM-DD" strings. They must be stored in AYON as midnight UTC, whatever the timezone of the machine running the service.

prague_timezone(monkeypatch)

Run the test as if the service machine was in Europe/Prague.

Source code in services/tests/test_date_conversion.py
53
54
55
56
57
58
59
60
61
62
63
@pytest.fixture
def prague_timezone(monkeypatch):
    """Run the test as if the service machine was in Europe/Prague."""
    if not hasattr(time, "tzset"):
        pytest.skip("time.tzset() is not available on this platform.")

    monkeypatch.setenv("TZ", "Europe/Prague")
    time.tzset()
    yield
    monkeypatch.undo()
    time.tzset()

test_naive_date_shifts_with_local_timezone(prague_timezone)

Document the issue: a naive midnight is serialized in local time.

Source code in services/tests/test_date_conversion.py
82
83
84
85
def test_naive_date_shifts_with_local_timezone(prague_timezone):
    """Document the issue: a naive midnight is serialized in local time."""
    naive = datetime.datetime(2026, 9, 3)
    assert _sent_to_server(naive) == "2026-09-02T22:00:00+00:00"