Coverage for src/kwai/modules/portal/pages/page_query.py: 100%
5 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 an interface for a page query."""
3from abc import abstractmethod
5from kwai.core.domain.repository.query import Query
6from kwai.core.domain.value_objects.unique_id import UniqueId
7from kwai.modules.portal.pages.page import PageIdentifier
10class PageQuery(Query):
11 """An interface for a page query."""
13 @abstractmethod
14 def filter_by_id(self, id_: PageIdentifier) -> "PageQuery":
15 """Add a filter on the page id.
17 Args:
18 id_: an id of a page.
19 """
20 raise NotImplementedError
22 @abstractmethod
23 def filter_by_application(self, application: int | str) -> "PageQuery":
24 """Add a filter to return only pages for the given application.
26 Args:
27 application: The id or the name of the application
28 """
29 raise NotImplementedError
31 @abstractmethod
32 def filter_by_active(self) -> "PageQuery":
33 """Add a filter to only return active pages."""
34 raise NotImplementedError
36 @abstractmethod
37 def filter_by_user(self, user: int | UniqueId) -> "PageQuery":
38 """Add a filter to only return pages of the given user.
40 Args:
41 user: The id or unique id of the user.
42 """
43 raise NotImplementedError