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

4 statements  

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

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

2 

3from abc import ABC, abstractmethod 

4 

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

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

7 

8 

9class ApplicationQuery(Query, ABC): 

10 """An interface for querying applications.""" 

11 

12 @abstractmethod 

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

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

15 

16 Args: 

17 id_: an id of an application. 

18 """ 

19 raise NotImplementedError 

20 

21 @abstractmethod 

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

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

24 

25 Args: 

26 name: the name of an application. 

27 """ 

28 raise NotImplementedError 

29 

30 @abstractmethod 

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

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

33 raise NotImplementedError 

34 

35 @abstractmethod 

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

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

38 raise NotImplementedError 

39 

40 @abstractmethod 

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

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

43 raise NotImplementedError