Coverage for bc/kwai-bc-portal/src/kwai_bc_portal/applications/application_query.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.11.0, 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 

6 

7from kwai_bc_portal.domain.application import ApplicationIdentifier 

8 

9 

10class ApplicationQuery(Query, ABC): 

11 """An interface for querying applications.""" 

12 

13 @abstractmethod 

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

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

16 

17 Args: 

18 id_: an id of an application. 

19 """ 

20 raise NotImplementedError 

21 

22 @abstractmethod 

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

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

25 

26 Args: 

27 name: the name of an application. 

28 """ 

29 raise NotImplementedError 

30 

31 @abstractmethod 

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

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

34 raise NotImplementedError 

35 

36 @abstractmethod 

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

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

39 raise NotImplementedError 

40 

41 @abstractmethod 

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

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

44 raise NotImplementedError