Coverage for kwai/modules/portal/applications/application_query.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-09-05 17:55 +0000

1"""Module that defines an interface for an application query.""" 

2from abc import ABC, abstractmethod 

3 

4from kwai.core.domain.repository.query import Query 

5from kwai.modules.portal.applications.application import ApplicationIdentifier 

6 

7 

8class ApplicationQuery(Query, ABC): 

9 """An interface for querying applications.""" 

10 

11 @abstractmethod 

12 def filter_by_id(self, id_: ApplicationIdentifier) -> "ApplicationQuery": 

13 """Add a filter on the application id. 

14 

15 Args: 

16 id_: an id of an application. 

17 """ 

18 raise NotImplementedError 

19 

20 @abstractmethod 

21 def filter_by_name(self, name: str) -> "ApplicationQuery": 

22 """Add a filter on the application name. 

23 

24 Args: 

25 name: the name of an application. 

26 """ 

27 raise NotImplementedError 

28 

29 @abstractmethod 

30 def filter_only_news(self) -> "ApplicationQuery": 

31 """Only return applications which can contain news.""" 

32 raise NotImplementedError 

33 

34 @abstractmethod 

35 def filter_only_pages(self) -> "ApplicationQuery": 

36 """Only return applications which can contain pages.""" 

37 raise NotImplementedError 

38 

39 @abstractmethod 

40 def filter_only_events(self) -> "ApplicationQuery": 

41 """Only return applications which can contain events.""" 

42 raise NotImplementedError