Coverage for server / validators / feature_enum.py: 74%

23 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-10-04 09:33 +0000

1from enum import Enum 

2 

3 

4class StatusEnum(str, Enum): 

5 ON = "on" 

6 OFF = "off" 

7 

8 

9class PlanEnum(str, Enum): 

10 FREE = "free" 

11 BASIC = "basic" 

12 INTERMEDIATE = "intermediate" 

13 PREMIUM = "premium" 

14 

15 

16PLAN_TIER_ORDER = [ 

17 PlanEnum.FREE.value, 

18 PlanEnum.BASIC.value, 

19 PlanEnum.INTERMEDIATE.value, 

20 PlanEnum.PREMIUM.value, 

21] 

22 

23 

24LEGACY_PLAN_ALIASES = { 

25 "starter": PlanEnum.FREE.value, 

26 "professional": PlanEnum.INTERMEDIATE.value, 

27 "enterprise": PlanEnum.PREMIUM.value, 

28 "enterprise plan": PlanEnum.PREMIUM.value, 

29 "trial": PlanEnum.FREE.value, 

30 "basic plan": PlanEnum.BASIC.value, 

31 "premium plan": PlanEnum.PREMIUM.value, 

32 "intermediate plan": PlanEnum.INTERMEDIATE.value, 

33 "free plan": PlanEnum.FREE.value, 

34} 

35 

36 

37def normalize_plan_type(plan_type: str) -> str: 

38 """Map legacy plan tier names to the current tier set.""" 

39 lowered = plan_type.strip().lower() 

40 return LEGACY_PLAN_ALIASES.get(lowered, lowered) 

41 

42 

43def plans_included_through(plan_type: str) -> list[str]: 

44 """Return all plan tiers included in a cumulative subscription level.""" 

45 normalized = normalize_plan_type(plan_type) 

46 try: 

47 index = PLAN_TIER_ORDER.index(normalized) 

48 except ValueError as exc: 

49 raise ValueError( 

50 f"Invalid plan type. Valid types are: {', '.join(PLAN_TIER_ORDER)}." 

51 ) from exc 

52 return PLAN_TIER_ORDER[: index + 1] 

53 

54 

55PLAN_DISPLAY_NAMES = { 

56 PlanEnum.FREE.value: "Free", 

57 PlanEnum.BASIC.value: "Basic", 

58 PlanEnum.INTERMEDIATE.value: "Intermediate", 

59 PlanEnum.PREMIUM.value: "Premium", 

60} 

61 

62 

63PLAN_DESCRIPTIONS = { 

64 PlanEnum.FREE.value: "Essential features for small schools and districts", 

65 PlanEnum.BASIC.value: "Core features for growing schools and districts", 

66 PlanEnum.INTERMEDIATE.value: "Advanced features for growing institutions", 

67 PlanEnum.PREMIUM.value: "Comprehensive features for large institutions", 

68}