You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
# backend/app/connectors/calendar/mock.py — 시드 기반 calendar sync (phase-13)
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlmodel import Session
|
|
|
|
from ..base import BaseConnector, NormalizedRecord, RawRecord
|
|
from .normalize import normalize_event, upsert_event
|
|
|
|
_SIM = [
|
|
{
|
|
"id": "sim-e1",
|
|
"day": 10,
|
|
"start": "16:00",
|
|
"end": "16:30",
|
|
"title": "현우님 일정 제안 — 온보딩 핸드오프",
|
|
"cal": "work",
|
|
"loc": "Figma",
|
|
"note": "",
|
|
"soon": False,
|
|
"people": "현우",
|
|
}
|
|
]
|
|
|
|
|
|
class MockCalendarConnector(BaseConnector):
|
|
domain = "calendar"
|
|
entity_type = "event"
|
|
|
|
def fetch(self, session: Session, *, full: bool = False):
|
|
for p in getattr(self, "_sim_payloads", []):
|
|
yield RawRecord(
|
|
external_id=p["id"],
|
|
payload=p,
|
|
etag=f"{p.get('start', '')}-{p.get('title', '')}",
|
|
external_updated_at=datetime.now(UTC),
|
|
)
|
|
|
|
def simulate_new(self) -> "MockCalendarConnector":
|
|
self._sim_payloads = _SIM
|
|
return self
|
|
|
|
def normalize(self, raw: RawRecord) -> NormalizedRecord:
|
|
return normalize_event(self.account, raw)
|
|
|
|
def write(self, session: Session, norm: NormalizedRecord):
|
|
return upsert_event(session, norm)
|
|
|
|
def event_for(self, norm, entity_id):
|
|
return "calendar.updated"
|