Coverage for src/kwai/modules/portal/get_page.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-01-01 00:00 +0000

1"""Module for the use case "Get Page".""" 

2 

3from dataclasses import dataclass 

4 

5from kwai.modules.portal.pages.page import PageEntity, PageIdentifier 

6from kwai.modules.portal.pages.page_repository import PageRepository 

7 

8 

9@dataclass(kw_only=True, frozen=True, slots=True) 

10class GetPageCommand: 

11 """Input for the use case "Get Page".""" 

12 

13 id: int 

14 

15 

16class GetPage: 

17 """Use case "Get Page".""" 

18 

19 def __init__(self, repo: PageRepository): 

20 """Initialize the use case. 

21 

22 Args: 

23 repo: A repository to get the page. 

24 """ 

25 self._repo = repo 

26 

27 async def execute(self, command: GetPageCommand) -> PageEntity: 

28 """Execute the use case.""" 

29 return await self._repo.get_by_id(PageIdentifier(command.id))