Coverage for polar/benefit/strategies/custom/service.py: 69%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 16:17 +0000

1from typing import Any, cast 1a

2 

3from polar.auth.models import AuthSubject 1a

4from polar.models import Benefit, Customer, Organization, User 1a

5 

6from ..base.service import BenefitServiceProtocol 1a

7from .properties import BenefitCustomProperties, BenefitGrantCustomProperties 1a

8 

9 

10class BenefitCustomService( 1a

11 BenefitServiceProtocol[BenefitCustomProperties, BenefitGrantCustomProperties] 

12): 

13 async def grant( 1a

14 self, 

15 benefit: Benefit, 

16 customer: Customer, 

17 grant_properties: BenefitGrantCustomProperties, 

18 *, 

19 update: bool = False, 

20 attempt: int = 1, 

21 ) -> BenefitGrantCustomProperties: 

22 return {} 

23 

24 async def cycle( 1a

25 self, 

26 benefit: Benefit, 

27 customer: Customer, 

28 grant_properties: BenefitGrantCustomProperties, 

29 *, 

30 attempt: int = 1, 

31 ) -> BenefitGrantCustomProperties: 

32 return {} 

33 

34 async def revoke( 1a

35 self, 

36 benefit: Benefit, 

37 customer: Customer, 

38 grant_properties: BenefitGrantCustomProperties, 

39 *, 

40 attempt: int = 1, 

41 ) -> BenefitGrantCustomProperties: 

42 return {} 

43 

44 async def requires_update( 1a

45 self, benefit: Benefit, previous_properties: BenefitCustomProperties 

46 ) -> bool: 

47 return False 

48 

49 async def validate_properties( 1a

50 self, auth_subject: AuthSubject[User | Organization], properties: dict[str, Any] 

51 ) -> BenefitCustomProperties: 

52 return cast(BenefitCustomProperties, properties)