-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared: Migrate to Plan / Tier Tables #479
Changes from 1 commit
fbbb396
52fdc2d
33d98f6
ba68a8b
3b1deb6
7eb00e4
4fd5090
7473f20
ccb28ab
208eb10
a9a5eeb
3dcd8ef
6b1fabc
906e7bc
2cd7436
8277f6d
5c8398a
d2c0af3
7804571
0e2207e
6e1418a
a4bd8f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,7 +220,7 @@ def pretty_plan(self) -> dict | None: | |
This is how we represent the details of a plan to a user, see plan.constants.py | ||
We inject quantity to make plan management easier on api, see PlanSerializer | ||
""" | ||
plan_details = Plan.objects.get(name=self.plan) | ||
plan_details = Plan.objects.select_related("tier").get(name=self.plan) | ||
if plan_details: | ||
return { | ||
"marketing_name": plan_details.marketing_name, | ||
|
@@ -605,7 +605,8 @@ def pretty_plan(self): | |
if self.account: | ||
return self.account.pretty_plan | ||
|
||
plan_details = Plan.objects.get(name=self.plan) | ||
print("@@@@@@@@@@@@@@@@@@@@", self.plan) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another print 🖨️ |
||
plan_details = Plan.objects.select_related("tier").get(name=self.plan) | ||
if plan_details: | ||
return { | ||
"marketing_name": plan_details.marketing_name, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,24 @@ class TierName(enum.Enum): | |
TRIAL = "trial" | ||
|
||
|
||
def convert_to_DTO(plan) -> dict: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Swatinem this guy |
||
return { | ||
"marketing_name": plan.marketing_name, | ||
"value": plan.name, | ||
"billing_rate": plan.billing_rate, | ||
"base_unit_price": plan.base_unit_price, | ||
"benefits": plan.benefits, | ||
"tier_name": plan.tier.tier_name, | ||
"monthly_uploads_limit": plan.monthly_uploads_limit, | ||
"is_free_plan": not plan.paid_plan, | ||
"is_pro_plan": plan.tier.tier_name == TierName.PRO.value, | ||
"is_team_plan": plan.tier.tier_name == TierName.TEAM.value, | ||
"is_enterprise_plan": plan.tier.tier_name == TierName.ENTERPRISE.value, | ||
"is_trial_plan": plan.tier.tier_name == TierName.TRIAL.value, | ||
"is_sentry_plan": plan.tier.tier_name == TierName.SENTRY.value, | ||
} | ||
|
||
|
||
@dataclass(repr=False) | ||
class PlanData: | ||
""" | ||
|
@@ -110,24 +128,6 @@ def convert_to_DTO(self) -> dict: | |
} | ||
|
||
|
||
def convert_to_DTO(plan) -> dict: | ||
return { | ||
"marketing_name": plan.marketing_name, | ||
"value": plan.name, | ||
"billing_rate": plan.billing_rate, | ||
"base_unit_price": plan.base_unit_price, | ||
"benefits": plan.benefits, | ||
"tier_name": plan.tier.tier_name, | ||
"monthly_uploads_limit": plan.monthly_uploads_limit, | ||
"is_free_plan": not plan.paid_plan, | ||
"is_pro_plan": plan.tier.tier_name == TierName.PRO.value, | ||
"is_team_plan": plan.tier.tier_name == TierName.TEAM.value, | ||
"is_enterprise_plan": plan.tier.tier_name == TierName.ENTERPRISE.value, | ||
"is_trial_plan": plan.tier.tier_name == TierName.TRIAL.value, | ||
"is_sentry_plan": plan.tier.tier_name == TierName.SENTRY.value, | ||
} | ||
|
||
|
||
NON_PR_AUTHOR_PAID_USER_PLAN_REPRESENTATIONS = { | ||
PlanName.CODECOV_PRO_MONTHLY_LEGACY.value: PlanData( | ||
marketing_name=PlanMarketingName.CODECOV_PRO.value, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
class TestOwnerModel(TransactionTestCase): | ||
def setUp(self): | ||
self.owner = OwnerFactory(username="codecov_name", email="[email protected]") | ||
mock_all_plans_and_tiers() | ||
|
||
def test_repo_total_credits_returns_correct_repos_for_legacy_plan(self): | ||
self.owner.plan = "5m" | ||
|
@@ -379,6 +378,7 @@ def test_can_activate_user_cannot_activate_account(self): | |
assert not self.owner.can_activate_user(self.owner) | ||
|
||
def test_fields_that_account_overrides(self): | ||
mock_all_plans_and_tiers() | ||
to_activate = OwnerFactory() | ||
self.owner.plan = PlanName.BASIC_PLAN_NAME.value | ||
self.owner.plan_user_count = 1 | ||
|
@@ -398,12 +398,6 @@ def test_fields_that_account_overrides(self): | |
ENTERPRISE_CLOUD_USER_PLAN_REPRESENTATIONS[self.owner.account.plan] | ||
) | ||
account_pretty_plan.update({"quantity": 0}) | ||
print( | ||
"account_pretty_plan", | ||
account_pretty_plan, | ||
"self.owner.pretty_plan", | ||
self.owner.pretty_plan, | ||
) | ||
self.assertEqual(self.owner.pretty_plan, account_pretty_plan) | ||
|
||
def test_add_admin_adds_ownerid_to_admin_array(self): | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -22,7 +22,9 @@ | |||
|
||||
|
||||
class CoverageMeasurement(TestCase): | ||||
def setUp(self): | ||||
@classmethod | ||||
def setUpClass(cls): | ||||
super().setUpClass() | ||||
mock_all_plans_and_tiers() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need that here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bc of this: Line 35 in b186b3c
admittedly could probably be more precise with the mock here |
||||
|
||||
def add_upload_measurements_records( | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this a class method, like serialized plan or something