Coverage for src/kwai/modules/portal/delete_page.py: 100%
12 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module for defining the use case "Delete Page"."""
3from dataclasses import dataclass
5from kwai.modules.portal.pages.page import PageIdentifier
6from kwai.modules.portal.pages.page_repository import PageRepository
9@dataclass(kw_only=True, frozen=True, slots=True)
10class DeletePageCommand:
11 """Input for the use case "Delete Page"."""
13 id: int
16class DeletePage:
17 """Use case "Delete Page"."""
19 def __init__(self, repo: PageRepository):
20 """Initialize the use case.
22 Args:
23 repo: A repository for deleting a page.
24 """
25 self._repo = repo
27 async def execute(self, command: DeletePageCommand) -> None:
28 """Executes the use case.
30 Args:
31 command: The input for this use case.
33 Raises:
34 PageNotFoundException: when the page does not exist.
35 """
36 page = await self._repo.get_by_id(PageIdentifier(command.id))
37 await self._repo.delete(page)