-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new users-developer plan (#494)
* Add new developer plan * fix enum issue * Resolve tests * create a new default const for plans * fix lint issues * remove developer new enum key * remove deprecated
- Loading branch information
1 parent
c8dca74
commit 7ba099f
Showing
7 changed files
with
202 additions
and
117 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
shared/django_apps/codecov_auth/migrations/0065_alter_account_plan_alter_owner_plan.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generated by Django 4.2.16 on 2025-01-30 13:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
""" | ||
BEGIN; | ||
-- | ||
-- Alter field plan on account | ||
-- | ||
-- (no-op) | ||
-- | ||
-- Raw SQL operation | ||
-- | ||
ALTER TYPE plans ADD VALUE IF NOT EXISTS 'users-developer'; | ||
-- | ||
-- Alter field plan on owner | ||
-- | ||
-- (no-op) | ||
COMMIT; | ||
""" | ||
|
||
dependencies = [ | ||
("codecov_auth", "0064_plan_stripe_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="account", | ||
name="plan", | ||
field=models.CharField( | ||
choices=[ | ||
("users-basic", "BASIC_PLAN_NAME"), | ||
("users-trial", "TRIAL_PLAN_NAME"), | ||
("users-pr-inappm", "CODECOV_PRO_MONTHLY"), | ||
("users-pr-inappy", "CODECOV_PRO_YEARLY"), | ||
("users-sentrym", "SENTRY_MONTHLY"), | ||
("users-sentryy", "SENTRY_YEARLY"), | ||
("users-teamm", "TEAM_MONTHLY"), | ||
("users-teamy", "TEAM_YEARLY"), | ||
("users", "GHM_PLAN_NAME"), | ||
("users-free", "FREE_PLAN_NAME"), | ||
("users-inappm", "CODECOV_PRO_MONTHLY_LEGACY"), | ||
("users-inappy", "CODECOV_PRO_YEARLY_LEGACY"), | ||
("users-enterprisem", "ENTERPRISE_CLOUD_MONTHLY"), | ||
("users-enterprisey", "ENTERPRISE_CLOUD_YEARLY"), | ||
("users-developer", "USERS_DEVELOPER"), | ||
], | ||
default="users-developer", | ||
max_length=50, | ||
), | ||
), | ||
migrations.RunSQL( | ||
"ALTER TYPE plans ADD VALUE IF NOT EXISTS 'users-developer';" | ||
), | ||
migrations.AlterField( | ||
model_name="owner", | ||
name="plan", | ||
field=models.TextField(blank=True, default="users-developer", null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ | |
) | ||
from shared.django_apps.core.tests.factories import RepositoryFactory | ||
from shared.plan.constants import ( | ||
BASIC_PLAN, | ||
DEFAULT_FREE_PLAN, | ||
DEVELOPER_PLAN, | ||
ENTERPRISE_CLOUD_USER_PLAN_REPRESENTATIONS, | ||
PlanName, | ||
) | ||
|
@@ -380,11 +381,11 @@ def test_can_activate_user_cannot_activate_account(self): | |
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 = DEFAULT_FREE_PLAN | ||
self.owner.plan_user_count = 1 | ||
self.owner.save() | ||
self.assertTrue(self.owner.can_activate_user(to_activate)) | ||
org_pretty_plan = asdict(BASIC_PLAN) | ||
org_pretty_plan = asdict(DEVELOPER_PLAN) | ||
org_pretty_plan.update({"quantity": 1}) | ||
self.assertEqual(self.owner.pretty_plan, org_pretty_plan) | ||
|
||
|
@@ -527,7 +528,7 @@ def test_has_yaml(self): | |
|
||
class TestOrganizationLevelTokenModel(TestCase): | ||
def test_can_save_org_token_for_org_basic_plan(self): | ||
owner = OwnerFactory(plan="users-basic") | ||
owner = OwnerFactory(plan=DEFAULT_FREE_PLAN) | ||
owner.save() | ||
token = OrganizationLevelToken(owner=owner) | ||
token.save() | ||
|
@@ -545,7 +546,7 @@ def test_token_is_deleted_when_changing_user_plan( | |
owner.save() | ||
org_token.save() | ||
assert OrganizationLevelToken.objects.filter(owner=owner).count() == 1 | ||
owner.plan = "users-basic" | ||
owner.plan = DEFAULT_FREE_PLAN | ||
owner.save() | ||
assert OrganizationLevelToken.objects.filter(owner=owner).count() == 0 | ||
|
||
|
@@ -759,7 +760,7 @@ def test_account_with_users(self): | |
self.assertEqual(account.activated_student_count, 0) | ||
self.assertEqual(account.total_seat_count, 1) | ||
self.assertEqual(account.available_seat_count, 0) | ||
pretty_plan = asdict(BASIC_PLAN) | ||
pretty_plan = asdict(DEVELOPER_PLAN) | ||
pretty_plan.update({"quantity": 1}) | ||
self.assertEqual(account.pretty_plan, pretty_plan) | ||
|
||
|
@@ -772,21 +773,21 @@ def test_create_account_for_enterprise_experience(self): | |
user_for_owner_1 = UserFactory(email="[email protected]", name="Luigi") | ||
owner_1 = OwnerFactory( | ||
username="codecov-1", | ||
plan=PlanName.BASIC_PLAN_NAME.value, | ||
plan=DEFAULT_FREE_PLAN, | ||
plan_user_count=1, | ||
organizations=[], | ||
user_id=user_for_owner_1.id, # has user | ||
) | ||
owner_2 = OwnerFactory( | ||
username="codecov-sentry", | ||
plan=PlanName.BASIC_PLAN_NAME.value, | ||
plan=DEFAULT_FREE_PLAN, | ||
plan_user_count=1, | ||
organizations=[], | ||
user_id=None, # no user | ||
) | ||
owner_3 = OwnerFactory( | ||
username="sentry-1", | ||
plan=PlanName.BASIC_PLAN_NAME.value, | ||
plan=DEFAULT_FREE_PLAN, | ||
plan_user_count=1, | ||
organizations=[], | ||
user_id=None, # no user | ||
|
@@ -810,7 +811,7 @@ def test_create_account_for_enterprise_experience(self): | |
username="codecov-org", | ||
stripe_customer_id=stripe_customer_id, | ||
stripe_subscription_id=stripe_subscription_id, | ||
plan=PlanName.BASIC_PLAN_NAME.value, | ||
plan=DEFAULT_FREE_PLAN, | ||
plan_user_count=50, | ||
plan_activated_users=[owner_1.ownerid, owner_2.ownerid], | ||
free=10, | ||
|
@@ -930,7 +931,7 @@ def test_create_account_for_enterprise_experience(self): | |
self.assertEqual(enterprise_account.activated_student_count, 0) | ||
self.assertEqual(enterprise_account.total_seat_count, 60) | ||
self.assertEqual(enterprise_account.available_seat_count, 57) | ||
pretty_plan = asdict(BASIC_PLAN) | ||
pretty_plan = asdict(DEVELOPER_PLAN) | ||
pretty_plan.update({"quantity": 50}) | ||
self.assertEqual(enterprise_account.pretty_plan, pretty_plan) | ||
|
||
|
Oops, something went wrong.