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.
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
# backend/tests/test_seed_calendar.py
|
|
# 주의: 이 프로젝트 conftest 의 `session` fixture 는 시드를 적재하지 않는다.
|
|
# `client` 가 같은 엔진에 시드를 적재하므로, DB 직접 접근 테스트는 (client, session) 둘 다 요청한다.
|
|
from sqlmodel import select
|
|
|
|
from app.models import Calendar, CalEvent, FocusBlock, Meeting, MeetingAction
|
|
|
|
|
|
def test_calendar_seed_counts(client, session):
|
|
s, _ = session
|
|
assert len(s.exec(select(Calendar)).all()) == 5
|
|
assert len(s.exec(select(CalEvent)).all()) == 22
|
|
assert len(s.exec(select(FocusBlock)).all()) == 4
|
|
assert {m.id for m in s.exec(select(Meeting)).all()} == {"e3", "e4", "e6", "e7"}
|
|
e3 = [a for a in s.exec(select(MeetingAction)).all() if a.meeting_id == "e3"]
|
|
assert len(e3) == 3
|
|
assert sum(1 for a in e3 if not a.added) == 1
|
|
|
|
|
|
def test_focus_seed_deep(client, session):
|
|
s, _ = session
|
|
deep = [f for f in s.exec(select(FocusBlock)).all() if f.type == "deep"]
|
|
assert len(deep) == 1 and deep[0].id == "f3"
|
|
assert deep[0].start == "15:10" and deep[0].end == "16:25"
|
|
|
|
|
|
def test_event_actions_seeded(client, session):
|
|
s, _ = session
|
|
eacts = [a for a in s.exec(select(MeetingAction)).all() if a.source == "event"]
|
|
assert {a.event_id for a in eacts} == {"e3", "e4"}
|
|
assert len(eacts) == 4
|