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

Commit 7ef477d

Browse files
Merge remote-tracking branch 'origin/main' into sshin/2849
2 parents a65bf87 + 1d7539e commit 7ef477d

File tree

22 files changed

+33
-1221
lines changed

22 files changed

+33
-1221
lines changed

api/internal/owner/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
TEAM_PLAN_MAX_USERS,
1313
TEAM_PLAN_REPRESENTATIONS,
1414
)
15+
from shared.plan.service import PlanService
1516

1617
from codecov_auth.models import Owner
17-
from plan.service import PlanService
1818
from services.billing import BillingService
1919
from services.sentry import send_user_webhook as send_sentry_webhook
2020

billing/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def test_customer_subscription_created_sets_plan_info(self):
571571
assert self.owner.plan == plan_name
572572

573573
@freeze_time("2023-06-19")
574-
@patch("plan.service.PlanService.expire_trial_when_upgrading")
574+
@patch("shared.plan.service.PlanService.expire_trial_when_upgrading")
575575
@patch("services.billing.stripe.PaymentMethod.attach")
576576
@patch("services.billing.stripe.Customer.modify")
577577
def test_customer_subscription_created_can_trigger_trial_expiration(

billing/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from rest_framework.permissions import AllowAny
1111
from rest_framework.response import Response
1212
from rest_framework.views import APIView
13+
from shared.plan.service import PlanService
1314

1415
from codecov_auth.models import Owner
15-
from plan.service import PlanService
1616
from services.task.task import TaskService
1717

1818
from .constants import StripeHTTPHeaders, StripeWebhookEvents

codecov_auth/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
StripeBilling,
2121
)
2222
from shared.plan.constants import USER_PLAN_REPRESENTATIONS
23+
from shared.plan.service import PlanService
2324

2425
from codecov.admin import AdminMixin
2526
from codecov.commands.exceptions import ValidationError
2627
from codecov_auth.helpers import History
2728
from codecov_auth.models import OrganizationLevelToken, Owner, SentryUser, Session, User
2829
from codecov_auth.services.org_level_token_service import OrgLevelTokenService
29-
from plan.service import PlanService
3030
from services.task import TaskService
3131
from utils.services import get_short_service_name
3232

codecov_auth/commands/owner/interactors/cancel_trial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from shared.plan.service import PlanService
2+
13
from codecov.commands.base import BaseInteractor
24
from codecov.commands.exceptions import Unauthorized, ValidationError
35
from codecov.db import sync_to_async
46
from codecov_auth.helpers import current_user_part_of_org
57
from codecov_auth.models import Owner
6-
from plan.service import PlanService
78

89

910
class CancelTrialInteractor(BaseInteractor):

codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
from shared.plan.service import PlanService
12
from shared.upload.utils import query_monthly_coverage_measurements
23

34
from codecov.commands.base import BaseInteractor
45
from codecov.db import sync_to_async
56
from codecov_auth.models import Owner
6-
from plan.service import PlanService
77
from services.redis_configuration import get_redis_connection
88

99
redis = get_redis_connection()

codecov_auth/commands/owner/interactors/start_trial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from shared.plan.service import PlanService
2+
13
from codecov.commands.base import BaseInteractor
24
from codecov.commands.exceptions import Unauthorized, ValidationError
35
from codecov.db import sync_to_async
46
from codecov_auth.helpers import current_user_part_of_org
57
from codecov_auth.models import Owner
6-
from plan.service import PlanService
78

89

910
class StartTrialInteractor(BaseInteractor):

codecov_auth/commands/owner/interactors/tests/test_cancel_trial.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from asgiref.sync import async_to_sync
55
from django.test import TransactionTestCase
66
from freezegun import freeze_time
7+
from shared.django_apps.codecov.commands.exceptions import ValidationError
78
from shared.django_apps.core.tests.factories import OwnerFactory
89
from shared.plan.constants import PlanName, TrialStatus
910

10-
from codecov.commands.exceptions import Unauthorized, ValidationError
11+
from codecov.commands.exceptions import Unauthorized
12+
from codecov.commands.exceptions import ValidationError as CodecovValidationError
1113
from codecov_auth.models import Owner
1214

1315
from ..cancel_trial import CancelTrialInteractor
@@ -26,7 +28,7 @@ def test_cancel_trial_raises_exception_when_owner_is_not_in_db(self):
2628
username="random-user-123",
2729
service="github",
2830
)
29-
with pytest.raises(ValidationError):
31+
with pytest.raises(CodecovValidationError):
3032
self.execute(current_user=current_user, org_username="some-other-username")
3133

3234
def test_cancel_trial_raises_exception_when_current_user_not_part_of_org(self):

codecov_auth/commands/owner/interactors/tests/test_start_trial.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from asgiref.sync import async_to_sync
55
from django.test import TransactionTestCase
66
from freezegun import freeze_time
7+
from shared.django_apps.codecov.commands.exceptions import ValidationError
78
from shared.django_apps.core.tests.factories import OwnerFactory
89
from shared.plan.constants import (
910
TRIAL_PLAN_SEATS,
@@ -12,7 +13,8 @@
1213
TrialStatus,
1314
)
1415

15-
from codecov.commands.exceptions import Unauthorized, ValidationError
16+
from codecov.commands.exceptions import Unauthorized
17+
from codecov.commands.exceptions import ValidationError as CodecovValidationError
1618
from codecov_auth.models import Owner
1719

1820
from ..start_trial import StartTrialInteractor
@@ -31,7 +33,7 @@ def test_start_trial_raises_exception_when_owner_is_not_in_db(self):
3133
username="random-user-123",
3234
service="github",
3335
)
34-
with pytest.raises(ValidationError):
36+
with pytest.raises(CodecovValidationError):
3537
self.execute(current_user=current_user, org_username="some-other-username")
3638

3739
def test_cancel_trial_raises_exception_when_current_user_not_part_of_org(self):

codecov_auth/tests/test_admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def test_start_trial_ui_display(self):
300300
assert res.status_code == 200
301301
assert "Extending trial for:" in str(res.content)
302302

303-
@patch("plan.service.PlanService.start_trial_manually")
303+
@patch("shared.plan.service.PlanService.start_trial_manually")
304304
def test_start_trial_action(self, mock_start_trial_service):
305305
mock_start_trial_service.return_value = None
306306
org_to_be_trialed = OwnerFactory()
@@ -317,7 +317,7 @@ def test_start_trial_action(self, mock_start_trial_service):
317317
assert res.status_code == 302
318318
assert mock_start_trial_service.called
319319

320-
@patch("plan.service.PlanService._start_trial_helper")
320+
@patch("shared.plan.service.PlanService._start_trial_helper")
321321
def test_extend_trial_action(self, mock_start_trial_service):
322322
mock_start_trial_service.return_value = None
323323
org_to_be_trialed = OwnerFactory()
@@ -337,7 +337,7 @@ 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")
340+
@patch("shared.plan.service.PlanService.start_trial_manually")
341341
def test_start_trial_paid_plan(self, mock_start_trial_service):
342342
mock_start_trial_service.side_effect = ValidationError(
343343
"Cannot trial from a paid plan"

0 commit comments

Comments
 (0)