Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 7819ab6

Browse files
Temporarily disable trials starting for paid orgs
1 parent aa55f93 commit 7819ab6

File tree

3 files changed

+43
-40
lines changed

3 files changed

+43
-40
lines changed

codecov_auth/tests/test_admin.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from shared.django_apps.core.tests.factories import PullFactory, RepositoryFactory
2727

28-
from codecov.commands.exceptions import ValidationError
28+
# from codecov.commands.exceptions import ValidationError
2929
from codecov_auth.admin import (
3030
AccountAdmin,
3131
InvoiceBillingAdmin,
@@ -337,25 +337,26 @@ def test_extend_trial_action(self, mock_start_trial_service):
337337
assert mock_start_trial_service.called
338338
assert mock_start_trial_service.call_args.kwargs == {"is_extension": True}
339339

340-
@patch("plan.service.PlanService.start_trial_manually")
341-
def test_start_trial_paid_plan(self, mock_start_trial_service):
342-
mock_start_trial_service.side_effect = ValidationError(
343-
"Cannot trial from a paid plan"
344-
)
345-
346-
org_to_be_trialed = OwnerFactory()
347-
348-
res = self.client.post(
349-
reverse("admin:codecov_auth_owner_changelist"),
350-
{
351-
"action": "extend_trial",
352-
ACTION_CHECKBOX_NAME: [org_to_be_trialed.pk],
353-
"end_date": "2024-01-01 01:02:03",
354-
"extend_trial": True,
355-
},
356-
)
357-
assert res.status_code == 302
358-
assert mock_start_trial_service.called
340+
# Temporarily comment for the time being
341+
# @patch("plan.service.PlanService.start_trial_manually")
342+
# def test_start_trial_paid_plan(self, mock_start_trial_service):
343+
# mock_start_trial_service.side_effect = ValidationError(
344+
# "Cannot trial from a paid plan"
345+
# )
346+
347+
# org_to_be_trialed = OwnerFactory()
348+
349+
# res = self.client.post(
350+
# reverse("admin:codecov_auth_owner_changelist"),
351+
# {
352+
# "action": "extend_trial",
353+
# ACTION_CHECKBOX_NAME: [org_to_be_trialed.pk],
354+
# "end_date": "2024-01-01 01:02:03",
355+
# "extend_trial": True,
356+
# },
357+
# )
358+
# assert res.status_code == 302
359+
# assert mock_start_trial_service.called
359360

360361
def test_account_widget(self):
361362
owner = OwnerFactory(user=UserFactory(), plan="users-enterprisey")

plan/service.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,16 @@ def start_trial_manually(self, current_owner: Owner, end_date: datetime) -> None
219219
Returns:
220220
No value
221221
"""
222-
# Start a new trial plan for free users currently not on trial
223-
if self.plan_name in FREE_PLAN_REPRESENTATIONS:
224-
self._start_trial_helper(current_owner, end_date, is_extension=False)
225222
# Extend an existing trial plan for users currently on trial
226-
elif self.plan_name in TRIAL_PLAN_REPRESENTATION:
223+
if self.plan_name in TRIAL_PLAN_REPRESENTATION:
227224
self._start_trial_helper(current_owner, end_date, is_extension=True)
228-
# Paying users cannot start a trial
225+
# Start a new trial plan for any users, used to be free but temporarily doing it for anyone
226+
# as long as the person extending the trial is responsible to manually returning the users
227+
# the way they were before
229228
else:
230-
raise ValidationError("Cannot trial from a paid plan")
229+
self._start_trial_helper(current_owner, end_date, is_extension=False)
230+
# Paying users cannot start a trial
231+
# raise ValidationError("Cannot trial from a paid plan")
231232

232233
def cancel_trial(self) -> None:
233234
if not self.is_org_trialing:

plan/tests/test_plan.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,21 @@ def test_plan_service_start_trial_manually(self):
226226
assert current_org.plan_auto_activate == True
227227
assert current_org.trial_fired_by == current_owner.ownerid
228228

229-
def test_plan_service_start_trial_manually_already_on_paid_plan(self):
230-
current_org = OwnerFactory(
231-
plan=PlanName.CODECOV_PRO_MONTHLY.value,
232-
trial_start_date=None,
233-
trial_end_date=None,
234-
trial_status=TrialStatus.NOT_STARTED.value,
235-
)
236-
plan_service = PlanService(current_org=current_org)
237-
current_owner = OwnerFactory()
238-
239-
with self.assertRaises(ValidationError):
240-
plan_service.start_trial_manually(
241-
current_owner=current_owner, end_date="2024-01-01 00:00:00"
242-
)
229+
# Temporarily comment this
230+
# def test_plan_service_start_trial_manually_already_on_paid_plan(self):
231+
# current_org = OwnerFactory(
232+
# plan=PlanName.CODECOV_PRO_MONTHLY.value,
233+
# trial_start_date=None,
234+
# trial_end_date=None,
235+
# trial_status=TrialStatus.NOT_STARTED.value,
236+
# )
237+
# plan_service = PlanService(current_org=current_org)
238+
# current_owner = OwnerFactory()
239+
240+
# with self.assertRaises(ValidationError):
241+
# plan_service.start_trial_manually(
242+
# current_owner=current_owner, end_date="2024-01-01 00:00:00"
243+
# )
243244

244245
def test_plan_service_returns_plan_data_for_non_trial_basic_plan(self):
245246
trial_start_date = None

0 commit comments

Comments
 (0)