Bugfixes in dashboard and calendar
This commit is contained in:
@@ -226,3 +226,116 @@ class TestPlanningService:
|
||||
assert vacation.day_type == "vacation"
|
||||
assert lagsta.day_type == "lagsta"
|
||||
assert sjuk.day_type == "sjukpenning"
|
||||
|
||||
async def test_list_by_child(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
seeded_ids: SeededIds,
|
||||
) -> None:
|
||||
"""List all planned days for a child."""
|
||||
child_id = seeded_ids.child_id
|
||||
|
||||
d1 = await planning_service.add_planned_day(
|
||||
workspace_id=seeded_ids.workspace_id,
|
||||
child_id=child_id,
|
||||
parent_personal_data_uuid=seeded_ids.personal_data_uuid,
|
||||
date=date(2026, 6, 15),
|
||||
day_type="vacation",
|
||||
)
|
||||
d2 = await planning_service.add_planned_day(
|
||||
workspace_id=seeded_ids.workspace_id,
|
||||
child_id=child_id,
|
||||
parent_personal_data_uuid=seeded_ids.personal_data_uuid,
|
||||
date=date(2026, 6, 16),
|
||||
day_type="lagsta",
|
||||
)
|
||||
|
||||
result = await planning_service.list_by_child(child_id)
|
||||
ids = {d.id for d in result}
|
||||
assert d1.id in ids
|
||||
assert d2.id in ids
|
||||
|
||||
async def test_list_by_child_empty(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
) -> None:
|
||||
"""Listing a child with no planned days returns empty."""
|
||||
result = await planning_service.list_by_child(uuid4())
|
||||
assert result == []
|
||||
|
||||
async def test_update_planned_day_day_type(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
seeded_ids: SeededIds,
|
||||
) -> None:
|
||||
"""Update the day_type of a planned day."""
|
||||
created = await planning_service.add_planned_day(
|
||||
workspace_id=seeded_ids.workspace_id,
|
||||
child_id=seeded_ids.child_id,
|
||||
parent_personal_data_uuid=seeded_ids.personal_data_uuid,
|
||||
date=date(2026, 6, 15),
|
||||
day_type="vacation",
|
||||
)
|
||||
|
||||
updated = await planning_service.update(
|
||||
created.id,
|
||||
day_type="lagsta",
|
||||
)
|
||||
assert updated.day_type == "lagsta"
|
||||
assert updated.date == date(2026, 6, 15)
|
||||
|
||||
async def test_update_planned_day_is_dubbeldag(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
seeded_ids: SeededIds,
|
||||
) -> None:
|
||||
"""Update the is_dubbeldag flag of a planned day."""
|
||||
created = await planning_service.add_planned_day(
|
||||
workspace_id=seeded_ids.workspace_id,
|
||||
child_id=seeded_ids.child_id,
|
||||
parent_personal_data_uuid=seeded_ids.personal_data_uuid,
|
||||
date=date(2026, 6, 15),
|
||||
day_type="vacation",
|
||||
is_dubbeldag=False,
|
||||
)
|
||||
|
||||
updated = await planning_service.update(
|
||||
created.id,
|
||||
is_dubbeldag=True,
|
||||
)
|
||||
assert updated.is_dubbeldag is True
|
||||
assert updated.day_type == "vacation"
|
||||
|
||||
async def test_update_planned_day_both_fields(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
seeded_ids: SeededIds,
|
||||
) -> None:
|
||||
"""Update both day_type and is_dubbeldag."""
|
||||
created = await planning_service.add_planned_day(
|
||||
workspace_id=seeded_ids.workspace_id,
|
||||
child_id=seeded_ids.child_id,
|
||||
parent_personal_data_uuid=seeded_ids.personal_data_uuid,
|
||||
date=date(2026, 6, 15),
|
||||
day_type="vacation",
|
||||
is_dubbeldag=False,
|
||||
)
|
||||
|
||||
updated = await planning_service.update(
|
||||
created.id,
|
||||
day_type="sjukpenning",
|
||||
is_dubbeldag=True,
|
||||
)
|
||||
assert updated.day_type == "sjukpenning"
|
||||
assert updated.is_dubbeldag is True
|
||||
|
||||
async def test_update_missing_raises(
|
||||
self,
|
||||
planning_service: PlanningService,
|
||||
) -> None:
|
||||
"""Updating a missing planned day raises NotFoundError."""
|
||||
with pytest.raises(NotFoundError):
|
||||
await planning_service.update(
|
||||
uuid4(),
|
||||
day_type="lagsta",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user