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

Commit 0d2d06a

Browse files
ajay-sentrymichelletran-sentry
authored andcommitted
ref: Fix Tests and last basic plan reference to DEFAULT_FREE_PLAN (#1085)
1 parent 94db1f9 commit 0d2d06a

File tree

13 files changed

+52
-36
lines changed

13 files changed

+52
-36
lines changed

database/models/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from functools import cached_property
66
from typing import Optional
77

8-
from shared.plan.constants import PlanName
8+
from shared.plan.constants import DEFAULT_FREE_PLAN
99
from sqlalchemy import Column, ForeignKey, Index, UniqueConstraint, types
1010
from sqlalchemy.dialects import postgresql
1111
from sqlalchemy.orm import Session, backref, relationship, validates
@@ -62,7 +62,7 @@ class Account(CodecovBaseModel, MixinBaseClassNoExternalID):
6262
plan = Column(
6363
types.String(50),
6464
nullable=False,
65-
default=PlanName.BASIC_PLAN_NAME.value, # TODO: UPDATE WITH NEW FREE PLAN NAME
65+
default=DEFAULT_FREE_PLAN,
6666
)
6767
plan_seat_count = Column(types.SmallInteger, nullable=False, default=1)
6868
free_seat_count = Column(types.SmallInteger, nullable=False, default=0)

database/tests/factories/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import factory
66
from factory import Factory
77
from shared.django_apps.codecov_auth.models import Plan, Tier
8-
from shared.plan.constants import PlanName, TierName
8+
from shared.plan.constants import DEFAULT_FREE_PLAN, TierName
99

1010
from database import enums, models
1111
from services.encryption import encryptor
@@ -51,7 +51,7 @@ class Meta:
5151
trial_status = enums.TrialStatus.NOT_STARTED.value
5252
trial_fired_by = None
5353
upload_token_required_for_public_repos = False
54-
plan = PlanName.BASIC_PLAN_NAME.value
54+
plan = DEFAULT_FREE_PLAN
5555

5656
oauth_token = factory.LazyAttribute(
5757
lambda o: encrypt_oauth_token(o.unencrypted_oauth_token)
@@ -325,7 +325,7 @@ class Meta:
325325
marketing_name = factory.Faker("catch_phrase")
326326
max_seats = 1
327327
monthly_uploads_limit = None
328-
name = PlanName.BASIC_PLAN_NAME.value
328+
name = DEFAULT_FREE_PLAN
329329
paid_plan = False
330330
stripe_id = None
331331

database/tests/unit/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import PropertyMock, call
33

44
from mock import MagicMock, patch
5-
from shared.plan.constants import PlanName
5+
from shared.plan.constants import DEFAULT_FREE_PLAN
66
from shared.reports.types import ReportTotals
77
from shared.storage.exceptions import FileNotInStorageError
88
from shared.utils.ReportEncoder import ReportEncoder
@@ -244,7 +244,7 @@ def test_create_account(self, dbsession):
244244
dbsession.refresh(account)
245245
assert account.name == "test_name"
246246
assert account.is_active is True
247-
assert account.plan == PlanName.BASIC_PLAN_NAME.value
247+
assert account.plan == DEFAULT_FREE_PLAN
248248
assert account.plan_seat_count == 1
249249
assert account.free_seat_count == 0
250250
assert account.plan_auto_activate is True

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser
2-
https://github.com/codecov/shared/archive/986a0971a633eac2a3005947102cb5f4d9119989.tar.gz#egg=shared
2+
https://github.com/codecov/shared/archive/016a756f2ab982016bc2d46e2467be71604c0ba5.tar.gz#egg=shared
33
https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring
44
asgiref>=3.7.2
55
analytics-python==1.3.0b1

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file was autogenerated by uv via the following command:
22
# uv pip compile requirements.in -o requirements.txt
3+
amplitude-analytics==1.1.4
4+
# via shared
35
amqp==5.2.0
46
# via kombu
57
analytics-python==1.3.0b1
@@ -377,7 +379,7 @@ sentry-sdk==2.13.0
377379
# shared
378380
setuptools==75.7.0
379381
# via nodeenv
380-
shared @ https://github.com/codecov/shared/archive/986a0971a633eac2a3005947102cb5f4d9119989.tar.gz#egg=shared
382+
shared @ https://github.com/codecov/shared/archive/016a756f2ab982016bc2d46e2467be71604c0ba5.tar.gz#egg=shared
381383
# via -r requirements.in
382384
six==1.16.0
383385
# via

services/tests/test_decoration.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from shared.django_apps.reports.tests.factories import (
1414
UploadFactory as DjangoUploadFactory,
1515
)
16-
from shared.plan.constants import PlanName
16+
from shared.plan.constants import DEFAULT_FREE_PLAN
1717
from shared.plan.service import PlanService
1818
from shared.upload.utils import UploaderType, insert_coverage_measurement
1919
from shared.utils.test_utils import mock_config_helper
@@ -229,7 +229,7 @@ def test_decoration_type_basic_plan_upload_limit(
229229
dbsession.add(pr_author)
230230
dbsession.flush()
231231

232-
enriched_pull.database_pull.repository.owner.plan = "users-basic"
232+
enriched_pull.database_pull.repository.owner.plan = DEFAULT_FREE_PLAN
233233
enriched_pull.database_pull.repository.private = True
234234

235235
commit = CommitFactory.create(
@@ -356,7 +356,7 @@ def test_decoration_type_unlimited_upload_on_enterprise(
356356
dbsession.add(pr_author)
357357
dbsession.flush()
358358

359-
enriched_pull.database_pull.repository.owner.plan = "users-basic"
359+
enriched_pull.database_pull.repository.owner.plan = DEFAULT_FREE_PLAN
360360
enriched_pull.database_pull.repository.private = True
361361

362362
commit = CommitFactory.create(
@@ -392,7 +392,7 @@ def test_uploads_used_with_expired_trial(self, mocker):
392392
trial_status=TrialStatus.EXPIRED.value,
393393
trial_start_date=datetime.now() + timedelta(days=-10),
394394
trial_end_date=datetime.now() + timedelta(days=-2),
395-
plan=PlanName.BASIC_PLAN_NAME.value,
395+
plan=DEFAULT_FREE_PLAN,
396396
)
397397
repository = DjangoRepositoryFactory(
398398
author=owner,
@@ -507,7 +507,7 @@ def test_get_decoration_type_for_users_plan(self, dbsession):
507507
owner__username="drazisil-org",
508508
owner__service="github",
509509
owner__unencrypted_oauth_token="testtfasdfasdflxuu2kfer2ef23",
510-
owner__plan=PlanName.BASIC_PLAN_NAME.value,
510+
owner__plan=DEFAULT_FREE_PLAN,
511511
private=True,
512512
)
513513
dbsession.add(repository)
@@ -706,11 +706,11 @@ def test_get_decoration_type_should_attempt_pr_author_auto_activation(
706706
)
707707

708708
@pytest.mark.django_db
709-
def test_get_decoration_type_should_attempt_pr_author_auto_activation_users_free(
709+
def test_get_decoration_type_should_attempt_pr_author_auto_activation_users_developer(
710710
self, dbsession, mocker, enriched_pull
711711
):
712-
enriched_pull.database_pull.repository.owner.plan = "users-free"
713-
enriched_pull.database_pull.repository.owner.plan_user_count = 5
712+
enriched_pull.database_pull.repository.owner.plan = DEFAULT_FREE_PLAN
713+
enriched_pull.database_pull.repository.owner.plan_user_count = 1
714714
enriched_pull.database_pull.repository.owner.plan_activated_users = []
715715
enriched_pull.database_pull.repository.owner.plan_auto_activate = True
716716

@@ -961,7 +961,7 @@ def test_uploads_used_with_expired_trial(self, mocker, dbsession):
961961
trial_status=TrialStatus.EXPIRED.value,
962962
trial_start_date=datetime.now() + timedelta(days=-10),
963963
trial_end_date=datetime.now() + timedelta(days=-2),
964-
plan=PlanName.BASIC_PLAN_NAME.value,
964+
plan=DEFAULT_FREE_PLAN,
965965
)
966966
repository = DjangoRepositoryFactory(
967967
author=owner,

services/tests/test_test_results.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import mock
22
import pytest
3+
from shared.plan.constants import DEFAULT_FREE_PLAN
34
from shared.torngit.exceptions import TorngitClientError
45

56
from database.models import UploadError
@@ -240,9 +241,9 @@ def test_notify_fail_torngit_error(
240241
"config,feature_flag,private,plan,ex_result",
241242
[
242243
(False, True, False, "users-inappm", False),
243-
(True, True, True, "users-basic", True),
244-
(True, False, False, "users-basic", True),
245-
(True, False, True, "users-basic", False),
244+
(True, True, True, DEFAULT_FREE_PLAN, True),
245+
(True, False, False, DEFAULT_FREE_PLAN, True),
246+
(True, False, True, DEFAULT_FREE_PLAN, False),
246247
(True, False, False, "users-inappm", True),
247248
(True, False, True, "users-inappm", True),
248249
],

tasks/tests/integration/test_upload_e2e.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from services.report import ReportService
2222
from tasks.tests.utils import hook_repo_provider, hook_session, run_tasks
2323
from tasks.upload import upload_task
24+
from tests.helpers import mock_all_plans_and_tiers
2425

2526

2627
def write_raw_upload(
@@ -171,6 +172,7 @@ def test_full_upload(
171172
mock_storage,
172173
mock_configuration,
173174
):
175+
mock_all_plans_and_tiers()
174176
setup_mocks(mocker, dbsession, mock_configuration, mock_repo_provider)
175177

176178
repository = RepositoryFactory.create()
@@ -377,6 +379,7 @@ def test_full_carryforward(
377379
mock_storage,
378380
mock_configuration,
379381
):
382+
mock_all_plans_and_tiers()
380383
user_yaml = {"flag_management": {"default_rules": {"carryforward": True}}}
381384
setup_mocks(
382385
mocker, dbsession, mock_configuration, mock_repo_provider, user_yaml=user_yaml

tasks/tests/unit/test_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from database.tests.factories.core import OwnerFactory, RepositoryFactory
2323
from tasks.base import BaseCodecovRequest, BaseCodecovTask
2424
from tasks.base import celery_app as base_celery_app
25+
from tests.helpers import mock_all_plans_and_tiers
2526

2627
here = Path(__file__)
2728

@@ -538,9 +539,11 @@ def test_apply_async_override_with_chain(self, mocker):
538539
)
539540

540541
@pytest.mark.freeze_time("2023-06-13T10:01:01.000123")
542+
@pytest.mark.django_db(databases={"default"})
541543
def test_real_example_no_override(
542544
self, mocker, dbsession, mock_configuration, fake_repos
543545
):
546+
mock_all_plans_and_tiers()
544547
mock_configuration.set_params(
545548
{
546549
"setup": {
@@ -583,9 +586,11 @@ def test_real_example_no_override(
583586
)
584587

585588
@pytest.mark.freeze_time("2023-06-13T10:01:01.000123")
589+
@pytest.mark.django_db(databases={"default"})
586590
def test_real_example_override_from_celery(
587591
self, mocker, dbsession, mock_configuration, fake_repos
588592
):
593+
mock_all_plans_and_tiers()
589594
mock_configuration.set_params(
590595
{
591596
"setup": {
@@ -628,9 +633,11 @@ def test_real_example_override_from_celery(
628633
)
629634

630635
@pytest.mark.freeze_time("2023-06-13T10:01:01.000123")
636+
@pytest.mark.django_db(databases={"default"})
631637
def test_real_example_override_from_upload(
632638
self, mocker, dbsession, mock_configuration, fake_repos
633639
):
640+
mock_all_plans_and_tiers()
634641
mock_configuration.set_params(
635642
{
636643
"setup": {

tasks/tests/unit/test_notify_task.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
_possibly_refresh_previous_selection,
5252
get_ta_relevant_context,
5353
)
54+
from tests.helpers import mock_all_plans_and_tiers
5455

5556

5657
def _start_upload_flow(mocker):
@@ -213,9 +214,11 @@ def test_determine_decoration_type_from_pull_auto_activation_fails(
213214
)
214215
assert not mock_schedule_new_user_activated_task.called
215216

217+
@pytest.mark.django_db(databases={"default"})
216218
def test_determine_decoration_type_from_pull_attempt_activation(
217219
self, dbsession, mocker, enriched_pull, with_sql_functions
218220
):
221+
mock_all_plans_and_tiers()
219222
pr_author = OwnerFactory.create(
220223
username=enriched_pull.provider_pull["author"]["username"],
221224
service_id=enriched_pull.provider_pull["author"]["id"],

0 commit comments

Comments
 (0)