Skip to content

Commit

Permalink
start BillingPlan deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
nora-codecov committed Jan 7, 2025
1 parent 340d059 commit 9e55b8a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
46 changes: 22 additions & 24 deletions shared/billing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
from enum import Enum

from django.conf import settings
from typing_extensions import deprecated

from shared.license import get_current_license
from shared.plan.constants import PlanName


@deprecated("Use PlanService")
class BillingPlan(Enum):
users_ghm = "users"
users_monthly = "users-inappm" # not pr_billing_plan
users_yearly = "users-inappy" # not pr_billing_plan
users_free = "users-free"
users_basic = "users-basic"
users_trial = "users-trial"
pr_monthly = "users-pr-inappm"
pr_yearly = "users-pr-inappy"
enterprise_cloud_yearly = "users-enterprisey"
enterprise_cloud_monthly = "users-enterprisem"
team_monthly = "users-teamm"
team_yearly = "users-teamy"
users_basic = PlanName.BASIC_PLAN_NAME.value
users_trial = PlanName.TRIAL_PLAN_NAME.value
pr_monthly = PlanName.CODECOV_PRO_MONTHLY.value
pr_yearly = PlanName.CODECOV_PRO_YEARLY.value
SENTRY_MONTHLY = PlanName.SENTRY_MONTHLY.value
SENTRY_YEARLY = PlanName.SENTRY_YEARLY.value
team_monthly = PlanName.TEAM_MONTHLY.value
team_yearly = PlanName.TEAM_YEARLY.value
users_ghm = PlanName.GHM_PLAN_NAME.value
users_free = PlanName.FREE_PLAN_NAME.value
users_monthly = PlanName.CODECOV_PRO_MONTHLY_LEGACY.value
users_yearly = PlanName.CODECOV_PRO_YEARLY_LEGACY.value
enterprise_cloud_monthly = PlanName.ENTERPRISE_CLOUD_MONTHLY.value
enterprise_cloud_yearly = PlanName.ENTERPRISE_CLOUD_YEARLY.value

def __init__(self, db_name):
self.db_name = db_name
Expand All @@ -29,27 +34,20 @@ def from_str(cls, plan_name: str):
return plan


@deprecated("use is_enterprise_plan() in PlanService")
def is_enterprise_cloud_plan(plan: BillingPlan) -> bool:
return plan in [
BillingPlan.enterprise_cloud_monthly,
BillingPlan.enterprise_cloud_yearly,
]


@deprecated("use is_pr_billing_plan() in PlanService")
def is_pr_billing_plan(plan: str) -> bool:
# use is_pr_billing_plan() in PlanService instead of accessing this directly
if not settings.IS_ENTERPRISE:
return plan in [
BillingPlan.pr_monthly.value,
BillingPlan.pr_yearly.value,
BillingPlan.users_free.value,
BillingPlan.users_basic.value,
BillingPlan.users_trial.value,
BillingPlan.enterprise_cloud_monthly.value,
BillingPlan.enterprise_cloud_yearly.value,
BillingPlan.team_monthly.value,
BillingPlan.team_yearly.value,
BillingPlan.users_ghm.value,
return plan not in [
PlanName.CODECOV_PRO_MONTHLY_LEGACY.value,
PlanName.CODECOV_PRO_YEARLY_LEGACY.value,
]
else:
return get_current_license().is_pr_billing
4 changes: 2 additions & 2 deletions shared/plan/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class PlanName(enum.Enum):
TRIAL_PLAN_NAME = "users-trial"
CODECOV_PRO_MONTHLY = "users-pr-inappm"
CODECOV_PRO_YEARLY = "users-pr-inappy"
SENTRY_MONTHLY = "users-sentrym" # not in BillingPlan
SENTRY_YEARLY = "users-sentryy" # not in BillingPlan
SENTRY_MONTHLY = "users-sentrym"
SENTRY_YEARLY = "users-sentryy"
TEAM_MONTHLY = "users-teamm"
TEAM_YEARLY = "users-teamy"
GHM_PLAN_NAME = "users"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plan/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def test_is_sentry_plan(self):
assert self.plan_service.is_free_plan == False
assert self.plan_service.is_pro_plan == True
assert self.plan_service.is_enterprise_plan == False
assert self.plan_service.is_pr_billing_plan == False
assert self.plan_service.is_pr_billing_plan == True

def test_is_free_plan(self):
self.current_org = OwnerFactory(
Expand Down

0 comments on commit 9e55b8a

Please sign in to comment.