Coverage for bc/kwai-bc-portal/src/kwai_bc_portal/pages/page_query.py: 100%

6 statements  

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

1"""Module for defining an interface for a page query.""" 

2 

3from abc import abstractmethod 

4from typing import Self 

5 

6from kwai_core.domain.repository.query import Query 

7from kwai_core.domain.value_objects.unique_id import UniqueId 

8 

9from kwai_bc_portal.domain.page import PageIdentifier 

10 

11 

12class PageQuery(Query): 

13 """An interface for a page query.""" 

14 

15 @abstractmethod 

16 def filter_by_id(self, id_: PageIdentifier) -> Self: 

17 """Add a filter on the page id. 

18 

19 Args: 

20 id_: an id of a page. 

21 """ 

22 raise NotImplementedError 

23 

24 @abstractmethod 

25 def filter_by_application(self, application: int | str) -> Self: 

26 """Add a filter to return only pages for the given application. 

27 

28 Args: 

29 application: The id or the name of the application 

30 """ 

31 raise NotImplementedError 

32 

33 @abstractmethod 

34 def filter_by_active(self) -> Self: 

35 """Add a filter to only return active pages.""" 

36 raise NotImplementedError 

37 

38 @abstractmethod 

39 def filter_by_user(self, user: int | UniqueId) -> Self: 

40 """Add a filter to only return pages of the given user. 

41 

42 Args: 

43 user: The id or unique id of the user. 

44 """ 

45 raise NotImplementedError