CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""Tests for user-timezone helpers (services/tz.py)."""
|
||
|
||
from datetime import datetime
|
||
from unittest.mock import AsyncMock, patch
|
||
from zoneinfo import ZoneInfo
|
||
|
||
import pytest
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_get_user_tz_returns_configured_zone():
|
||
from grimoire.services import tz as tz_mod
|
||
|
||
with patch.object(tz_mod, "get_setting", AsyncMock(return_value="America/New_York")):
|
||
zone = await tz_mod.get_user_tz(1)
|
||
assert zone == ZoneInfo("America/New_York")
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_get_user_tz_falls_back_to_utc_on_bad_input():
|
||
from grimoire.services import tz as tz_mod
|
||
|
||
with patch.object(tz_mod, "get_setting", AsyncMock(return_value="Not/AZone")):
|
||
zone = await tz_mod.get_user_tz(1)
|
||
assert zone == ZoneInfo("UTC")
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_user_day_date_before_4am_returns_yesterday():
|
||
"""00:00–03:59 local still shows yesterday's day_date."""
|
||
from grimoire.services import tz as tz_mod
|
||
|
||
ny = ZoneInfo("America/New_York")
|
||
# 02:00 NY on 2026-04-13 → day_date = 2026-04-12 (still pre-rollover)
|
||
fake_now = datetime(2026, 4, 13, 2, 0, tzinfo=ny)
|
||
|
||
class _FakeDatetime(datetime):
|
||
@classmethod
|
||
def now(cls, tz=None):
|
||
return fake_now
|
||
|
||
with patch.object(tz_mod, "get_user_tz", AsyncMock(return_value=ny)), \
|
||
patch.object(tz_mod, "datetime", _FakeDatetime):
|
||
day = await tz_mod.user_day_date(1)
|
||
assert day.isoformat() == "2026-04-12"
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_user_day_date_after_4am_returns_today():
|
||
from grimoire.services import tz as tz_mod
|
||
|
||
ny = ZoneInfo("America/New_York")
|
||
fake_now = datetime(2026, 4, 13, 4, 30, tzinfo=ny)
|
||
|
||
class _FakeDatetime(datetime):
|
||
@classmethod
|
||
def now(cls, tz=None):
|
||
return fake_now
|
||
|
||
with patch.object(tz_mod, "get_user_tz", AsyncMock(return_value=ny)), \
|
||
patch.object(tz_mod, "datetime", _FakeDatetime):
|
||
day = await tz_mod.user_day_date(1)
|
||
assert day.isoformat() == "2026-04-13"
|