From 1be033f8a8f78c127369a669e64e8ee32361816a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 15 Jan 2025 16:13:35 -0800 Subject: [PATCH 01/13] worker plan updates to use new plan model --- database/models/core.py | 4 +++- services/notification/__init__.py | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/database/models/core.py b/database/models/core.py index 5e2e85e59..2d3f7580d 100644 --- a/database/models/core.py +++ b/database/models/core.py @@ -59,7 +59,9 @@ class Account(CodecovBaseModel, MixinBaseClassNoExternalID): name = Column(types.String(100), nullable=False, unique=True) is_active = Column(types.Boolean, nullable=False, default=True) plan = Column( - types.String(50), nullable=False, default=PlanName.BASIC_PLAN_NAME.value + types.String(50), + nullable=False, + default=PlanName.BASIC_PLAN_NAME.value, # TODO: UPDATE WITH NEW FREE PLAN NAME ) plan_seat_count = Column(types.SmallInteger, nullable=False, default=1) free_seat_count = Column(types.SmallInteger, nullable=False, default=0) diff --git a/services/notification/__init__.py b/services/notification/__init__.py index ebe61543e..1c3d2ebe2 100644 --- a/services/notification/__init__.py +++ b/services/notification/__init__.py @@ -11,7 +11,7 @@ from celery.exceptions import CeleryError, SoftTimeLimitExceeded from shared.config import get_config from shared.helpers.yaml import default_if_true -from shared.plan.constants import TEAM_PLAN_REPRESENTATIONS +from shared.plan.constants import TierName from shared.torngit.base import TorngitBaseAdapter from shared.yaml import UserYaml @@ -66,9 +66,14 @@ def __init__( def _should_use_status_notifier(self, status_type: StatusType) -> bool: owner: Owner = self.repository.owner - if owner.plan in TEAM_PLAN_REPRESENTATIONS: - if status_type != StatusType.PATCH.value: - return False + if ( + owner.plan + in Plan.objects.filter(tier=TierName.TEAM.value).values_list( + "name", flat=True + ) + and status_type != StatusType.PATCH.value + ): + return False return True @@ -81,9 +86,14 @@ def _should_use_checks_notifier(self, status_type: StatusType) -> bool: if owner.service not in ["github", "github_enterprise"]: return False - if owner.plan in TEAM_PLAN_REPRESENTATIONS: - if status_type != StatusType.PATCH.value: - return False + if ( + owner.plan + in Plan.objects.filter(tier=TierName.TEAM.value).values_list( + "name", flat=True + ) + and status_type != StatusType.PATCH.value + ): + return False app_installation_filter = filter( lambda obj: ( From 7216f13058a7ebaf44c4cad882301002b703d660 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 17 Jan 2025 12:05:50 -0800 Subject: [PATCH 02/13] 81 failing tests, realized should start with shared --- database/tests/factories/core.py | 32 +++++++- requirements.in | 2 +- requirements.txt | 29 ++++--- services/notification/__init__.py | 15 ++-- .../tests/unit/test_notification_service.py | 77 +++++++++++++++---- services/test_results.py | 10 ++- 6 files changed, 127 insertions(+), 38 deletions(-) diff --git a/database/tests/factories/core.py b/database/tests/factories/core.py index 38905a3dd..2d8c6146c 100644 --- a/database/tests/factories/core.py +++ b/database/tests/factories/core.py @@ -4,7 +4,8 @@ import factory from factory import Factory -from shared.plan.constants import PlanName +from shared.django_apps.codecov_auth.models import Plan, Tier +from shared.plan.constants import PlanName, TierName from database import enums, models from services.encryption import encryptor @@ -298,3 +299,32 @@ class Meta: key = "" value = "" + + +class TierFactory(Factory): + class Meta: + model = Tier + + tier_name = TierName.BASIC.value + bundle_analysis = False + test_analytics = False + flaky_test_detection = False + project_coverage = False + private_repo_support = False + + +class PlanFactory(Factory): + class Meta: + model = Plan + + tier = factory.SubFactory(TierFactory) + base_unit_price = 0 + benefits = factory.LazyFunction(lambda: ["Benefit 1", "Benefit 2", "Benefit 3"]) + billing_rate = None + is_active = True + marketing_name = factory.Faker("catch_phrase") + max_seats = 1 + monthly_uploads_limit = None + name = PlanName.BASIC_PLAN_NAME.value + paid_plan = False + stripe_id = None diff --git a/requirements.in b/requirements.in index 9f737e5fd..414485856 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser -https://github.com/codecov/shared/archive/191837f5e35f5efc410e670aac7e50e0d09e43e1.tar.gz#egg=shared +https://github.com/codecov/shared/archive/52fdc2d14fa21d4c476d3264b021e42390b30c5f.tar.gz#egg=shared https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring asgiref>=3.7.2 analytics-python==1.3.0b1 diff --git a/requirements.txt b/requirements.txt index 34ecf93ad..680abe12f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,9 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile requirements.in -o requirements.txt +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile requirements.in +# amqp==5.2.0 # via kombu analytics-python==1.3.0b1 @@ -73,7 +77,7 @@ codecov-ribs==0.1.18 # shared colour==0.1.5 # via shared -coverage==7.5.0 +coverage[toml]==7.5.0 # via # -r requirements.in # pytest-cov @@ -111,7 +115,7 @@ filelock==3.12.4 # via virtualenv freezegun==1.5.0 # via pytest-freezegun -google-api-core==2.23.0 +google-api-core[grpc]==2.23.0 # via # google-cloud-bigquery # google-cloud-bigquery-storage @@ -151,7 +155,7 @@ google-resumable-media==2.7.2 # via # google-cloud-bigquery # google-cloud-storage -googleapis-common-protos==1.66.0 +googleapis-common-protos[grpc]==1.66.0 # via # google-api-core # grpc-google-iam-v1 @@ -363,19 +367,17 @@ requests==2.32.3 # stripe respx==0.20.2 # via -r requirements.in -rfc3986==1.4.0 +rfc3986[idna2008]==1.4.0 # via httpx rsa==4.7.2 # via google-auth s3transfer==0.10.1 # via boto3 -sentry-sdk==2.13.0 +sentry-sdk[celery]==2.13.0 # via # -r requirements.in # shared -setuptools==75.7.0 - # via nodeenv -shared @ https://github.com/codecov/shared/archive/191837f5e35f5efc410e670aac7e50e0d09e43e1.tar.gz#egg=shared +shared @ https://github.com/codecov/shared/archive/52fdc2d14fa21d4c476d3264b021e42390b30c5f.tar.gz # via -r requirements.in six==1.16.0 # via @@ -405,13 +407,13 @@ statsd==3.3.0 # via -r requirements.in stripe==11.4.1 # via -r requirements.in -test-results-parser @ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser +test-results-parser @ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz # via -r requirements.in text-unidecode==1.3 # via faker time-machine==2.14.1 # via -r requirements.in -timestring @ https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring +timestring @ https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz # via -r requirements.in tqdm==4.66.1 # via openai @@ -455,3 +457,6 @@ zstandard==0.23.0 # via # -r requirements.in # shared + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/services/notification/__init__.py b/services/notification/__init__.py index 1c3d2ebe2..778bc9a9c 100644 --- a/services/notification/__init__.py +++ b/services/notification/__init__.py @@ -10,6 +10,7 @@ from celery.exceptions import CeleryError, SoftTimeLimitExceeded from shared.config import get_config +from shared.django_apps.codecov_auth.models import Plan from shared.helpers.yaml import default_if_true from shared.plan.constants import TierName from shared.torngit.base import TorngitBaseAdapter @@ -66,11 +67,10 @@ def __init__( def _should_use_status_notifier(self, status_type: StatusType) -> bool: owner: Owner = self.repository.owner + plan = Plan.objects.get(name=owner.plan) + if ( - owner.plan - in Plan.objects.filter(tier=TierName.TEAM.value).values_list( - "name", flat=True - ) + plan.tier.tier_name == TierName.TEAM.value and status_type != StatusType.PATCH.value ): return False @@ -86,11 +86,10 @@ def _should_use_checks_notifier(self, status_type: StatusType) -> bool: if owner.service not in ["github", "github_enterprise"]: return False + plan = Plan.objects.get(name=owner.plan) + if ( - owner.plan - in Plan.objects.filter(tier=TierName.TEAM.value).values_list( - "name", flat=True - ) + plan.tier.tier_name == TierName.TEAM.value and status_type != StatusType.PATCH.value ): return False diff --git a/services/notification/tests/unit/test_notification_service.py b/services/notification/tests/unit/test_notification_service.py index 5dd73a533..334567946 100644 --- a/services/notification/tests/unit/test_notification_service.py +++ b/services/notification/tests/unit/test_notification_service.py @@ -1,11 +1,12 @@ import os from asyncio import CancelledError from asyncio import TimeoutError as AsyncioTimeoutError +from unittest.mock import patch import mock import pytest from celery.exceptions import SoftTimeLimitExceeded -from shared.plan.constants import PlanName +from shared.plan.constants import PlanName, TierName from shared.reports.resources import Report, ReportFile, ReportLine from shared.torngit.status import Status from shared.yaml import UserYaml @@ -16,6 +17,7 @@ GithubAppInstallation, ) from database.tests.factories import CommitFactory, PullFactory, RepositoryFactory +from database.tests.factories.core import PlanFactory, TierFactory from services.comparison import ComparisonProxy from services.comparison.types import Comparison, EnrichedPull, FullCommit from services.notification import NotificationService @@ -103,9 +105,13 @@ def test_should_use_checks_notifier_yaml_field_false(self, dbsession): ), ], ) + @patch("services.notification.Plan.objects.get") def test_should_use_checks_notifier_deprecated_flow( - self, repo_data, outcome, dbsession + self, plan_objects_get, repo_data, outcome, dbsession ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan + repository = RepositoryFactory.create(**repo_data) current_yaml = {"github_checks": True} assert repository.owner.github_app_installations == [] @@ -115,7 +121,12 @@ def test_should_use_checks_notifier_deprecated_flow( == outcome ) - def test_should_use_checks_notifier_ghapp_all_repos_covered(self, dbsession): + @patch("services.notification.Plan.objects.get") + def test_should_use_checks_notifier_ghapp_all_repos_covered( + self, plan_objects_get, dbsession + ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan repository = RepositoryFactory.create(owner__service="github") ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -133,9 +144,19 @@ def test_should_use_checks_notifier_ghapp_all_repos_covered(self, dbsession): == True ) - def test_use_checks_notifier_for_team_plan(self, dbsession): + @patch("services.notification.Plan.objects.get") + def test_use_checks_notifier_for_team_plan( + self, + plan_objects_get, + dbsession, + ): + tier = TierFactory.create( + tier_name=TierName.TEAM.value, + ) + plan = PlanFactory.create(tier=tier, name=PlanName.TEAM_MONTHLY.value) + plan_objects_get.return_value = plan repository = RepositoryFactory.create( - owner__service="github", owner__plan=PlanName.TEAM_MONTHLY.value + owner__service="github", owner__plan=plan.name ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -161,9 +182,16 @@ def test_use_checks_notifier_for_team_plan(self, dbsession): == True ) - def test_use_status_notifier_for_team_plan(self, dbsession): + @patch("services.notification.Plan.objects.get") + def test_use_status_notifier_for_team_plan(self, plan_objects_get, dbsession): + tier = TierFactory.create( + tier_name=TierName.TEAM.value, + ) + plan = PlanFactory.create(tier=tier, name=PlanName.TEAM_MONTHLY.value) + plan_objects_get.return_value = plan + repository = RepositoryFactory.create( - owner__service="github", owner__plan=PlanName.TEAM_MONTHLY.value + owner__service="github", owner__plan=plan.name ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -189,9 +217,15 @@ def test_use_status_notifier_for_team_plan(self, dbsession): == True ) - def test_use_status_notifier_for_non_team_plan(self, dbsession): + @patch("services.notification.Plan.objects.get") + def test_use_status_notifier_for_non_team_plan(self, plan_objects_get, dbsession): + tier = TierFactory.create( + tier_name=TierName.PRO.value, + ) + plan = PlanFactory.create(tier=tier, name=PlanName.CODECOV_PRO_MONTHLY.value) + plan_objects_get.return_value = plan repository = RepositoryFactory.create( - owner__service="github", owner__plan=PlanName.CODECOV_PRO_MONTHLY.value + owner__service="github", owner__plan=plan.name ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -221,9 +255,12 @@ def test_use_status_notifier_for_non_team_plan(self, dbsession): "gh_installation_name", [GITHUB_APP_INSTALLATION_DEFAULT_NAME, "notifications-app"], ) + @patch("services.notification.Plan.objects.get") def test_should_use_checks_notifier_ghapp_some_repos_covered( - self, dbsession, gh_installation_name + self, plan_objects_get, dbsession, gh_installation_name ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan repository = RepositoryFactory.create(owner__service="github") other_repo_same_owner = RepositoryFactory.create(owner=repository.owner) ghapp_installation = GithubAppInstallation( @@ -281,9 +318,12 @@ def test_get_notifiers_instances_only_third_party( assert instance.site_settings == ["slack.com"] assert instance.current_yaml == current_yaml + @patch("services.notification.Plan.objects.get") def test_get_notifiers_instances_checks( - self, dbsession, mock_configuration, mocker + self, plan_objects_get, dbsession, mock_configuration, mocker ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan repository = RepositoryFactory.create( owner__integration_id=123, owner__service="github", @@ -310,9 +350,12 @@ def test_get_notifiers_instances_checks( "codecov-slack-app", ] + @patch("services.notification.Plan.objects.get") def test_get_notifiers_instances_slack_app_false( - self, dbsession, mock_configuration, mocker + self, plan_objects_get, dbsession, mock_configuration, mocker ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan mocker.patch("services.notification.get_config", return_value=False) repository = RepositoryFactory.create( owner__integration_id=123, @@ -343,9 +386,17 @@ def test_get_notifiers_instances_slack_app_false( "gh_installation_name", [GITHUB_APP_INSTALLATION_DEFAULT_NAME, "notifications-app"], ) + @patch("services.notification.Plan.objects.get") def test_get_notifiers_instances_checks_percentage_whitelist( - self, dbsession, mock_configuration, mocker, gh_installation_name + self, + plan_objects_get, + dbsession, + mock_configuration, + mocker, + gh_installation_name, ): + plan = PlanFactory.create() + plan_objects_get.return_value = plan repository = RepositoryFactory.create( owner__integration_id=123, owner__service="github", diff --git a/services/test_results.py b/services/test_results.py index e9b67abe3..66b8bc207 100644 --- a/services/test_results.py +++ b/services/test_results.py @@ -3,7 +3,8 @@ from hashlib import sha256 from typing import Sequence -from shared.plan.constants import FREE_PLAN_REPRESENTATIONS, TEAM_PLAN_REPRESENTATIONS +from shared.django_apps.codecov_auth.models import Plan +from shared.plan.constants import TierName from shared.yaml import UserYaml from sqlalchemy import desc, distinct, func from sqlalchemy.orm import joinedload @@ -395,10 +396,13 @@ def get_test_summary_for_commit( def not_private_and_free_or_team(repo: Repository): + plan = Plan.objects.get(name=repo.owner.plan) return not ( repo.private - and repo.owner.plan - in {**FREE_PLAN_REPRESENTATIONS, **TEAM_PLAN_REPRESENTATIONS} + and ( + plan.tier.tier_name != TierName.FREE.value + and plan.tier.tier_name != TierName.TEAM.value + ) ) From aaffe2d658fa5ef296c65482e78ec5ffd1162835 Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Thu, 23 Jan 2025 13:25:15 +0100 Subject: [PATCH 03/13] resolve all unit tests --- database/tests/factories/core.py | 3 +- requirements.in | 2 +- requirements.txt | 27 ++- services/test_results.py | 2 +- tasks/tests/integration/test_notify_task.py | 11 ++ .../tests/unit/test_test_results_finisher.py | 17 +- tests/helpers.py | 154 ++++++++++++++++++ 7 files changed, 194 insertions(+), 22 deletions(-) create mode 100644 tests/helpers.py diff --git a/database/tests/factories/core.py b/database/tests/factories/core.py index ce0e64d75..1efefc28e 100644 --- a/database/tests/factories/core.py +++ b/database/tests/factories/core.py @@ -300,6 +300,7 @@ class Meta: key = "" value = "" + class TierFactory(Factory): class Meta: model = Tier @@ -328,6 +329,7 @@ class Meta: paid_plan = False stripe_id = None + class UploadErrorFactory(Factory): class Meta: model = models.UploadError @@ -335,4 +337,3 @@ class Meta: report_upload = factory.SubFactory(UploadFactory) error_code = "error" error_params = {"error_message": "error message"} - diff --git a/requirements.in b/requirements.in index 18781be69..e9af3532d 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser -https://github.com/codecov/shared/archive/d1762e32093ded26659cbe84757916f589fb87c2.tar.gz#egg=shared +https://github.com/codecov/shared/archive/906e7bc916e80d89583f2086a7e348c124bf6f72.tar.gz#egg=shared https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring asgiref>=3.7.2 analytics-python==1.3.0b1 diff --git a/requirements.txt b/requirements.txt index 23b096eb0..b9b3613a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,5 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in -o requirements.txt amqp==5.2.0 # via kombu analytics-python==1.3.0b1 @@ -77,7 +73,7 @@ codecov-ribs==0.1.18 # shared colour==0.1.5 # via shared -coverage[toml]==7.5.0 +coverage==7.5.0 # via # -r requirements.in # pytest-cov @@ -115,7 +111,7 @@ filelock==3.12.4 # via virtualenv freezegun==1.5.0 # via pytest-freezegun -google-api-core[grpc]==2.23.0 +google-api-core==2.23.0 # via # google-cloud-bigquery # google-cloud-bigquery-storage @@ -155,7 +151,7 @@ google-resumable-media==2.7.2 # via # google-cloud-bigquery # google-cloud-storage -googleapis-common-protos[grpc]==1.66.0 +googleapis-common-protos==1.66.0 # via # google-api-core # grpc-google-iam-v1 @@ -367,19 +363,19 @@ requests==2.32.3 # stripe respx==0.20.2 # via -r requirements.in -rfc3986[idna2008]==1.4.0 +rfc3986==1.4.0 # via httpx rsa==4.7.2 # via google-auth s3transfer==0.10.1 # via boto3 -sentry-sdk[celery]==2.13.0 +sentry-sdk==2.13.0 # via # -r requirements.in # shared setuptools==75.7.0 # via nodeenv -shared @ https://github.com/codecov/shared/archive/d1762e32093ded26659cbe84757916f589fb87c2.tar.gz#egg=shared +shared @ https://github.com/codecov/shared/archive/906e7bc916e80d89583f2086a7e348c124bf6f72.tar.gz#egg=shared # via -r requirements.in six==1.16.0 # via @@ -411,13 +407,13 @@ statsd==3.3.0 # via -r requirements.in stripe==11.4.1 # via -r requirements.in -test-results-parser @ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz +test-results-parser @ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser # via -r requirements.in text-unidecode==1.3 # via faker time-machine==2.14.1 # via -r requirements.in -timestring @ https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz +timestring @ https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring # via -r requirements.in tqdm==4.66.1 # via openai @@ -461,6 +457,3 @@ zstandard==0.23.0 # via # -r requirements.in # shared - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/services/test_results.py b/services/test_results.py index db9e38252..7b4727d08 100644 --- a/services/test_results.py +++ b/services/test_results.py @@ -454,7 +454,7 @@ def not_private_and_free_or_team(repo: Repository): return not ( repo.private and ( - plan.tier.tier_name != TierName.FREE.value + plan.tier.tier_name != TierName.BASIC.value and plan.tier.tier_name != TierName.TEAM.value ) ) diff --git a/tasks/tests/integration/test_notify_task.py b/tasks/tests/integration/test_notify_task.py index 407026f53..1aa3cc8b6 100644 --- a/tasks/tests/integration/test_notify_task.py +++ b/tasks/tests/integration/test_notify_task.py @@ -13,6 +13,7 @@ from services.notification.notifiers.base import NotificationResult from services.repository import EnrichedPull from tasks.notify import NotifyTask +from tests.helpers import mock_all_plans_and_tiers sample_token = "ghp_test6ldgmyaglf73gcnbi0kprz7dyjz6nzgn" @@ -28,7 +29,12 @@ def is_not_first_pull(mocker): @pytest.mark.integration class TestNotifyTask(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + @patch("requests.post") + @pytest.mark.django_db def test_simple_call_no_notifiers( self, mock_requests_post, @@ -155,6 +161,7 @@ def test_simple_call_no_notifiers( } @patch("requests.post") + @pytest.mark.django_db def test_simple_call_only_status_notifiers( self, mock_post_request, @@ -358,6 +365,7 @@ def test_simple_call_only_status_notifiers( } @patch("requests.post") + @pytest.mark.django_db def test_simple_call_only_status_notifiers_no_pull_request( self, mock_post_request, @@ -584,6 +592,7 @@ def test_simple_call_only_status_notifiers_no_pull_request( assert result == expected_result @patch("requests.post") + @pytest.mark.django_db def test_simple_call_only_status_notifiers_with_pull_request( self, mock_post_request, @@ -1265,6 +1274,7 @@ def test_simple_call_status_and_notifiers( pull = dbsession.query(Pull).filter_by(pullid=9, repoid=commit.repoid).first() assert pull.commentid == "1699669573" + @pytest.mark.django_db def test_notifier_call_no_head_commit_report( self, dbsession, mocker, codecov_vcr, mock_storage, mock_configuration ): @@ -1320,6 +1330,7 @@ def test_notifier_call_no_head_commit_report( } assert result == expected_result + @pytest.mark.django_db @patch("requests.post") def test_notifier_call_no_head_commit_report_empty_upload( self, diff --git a/tasks/tests/unit/test_test_results_finisher.py b/tasks/tests/unit/test_test_results_finisher.py index fa32e5366..b7921a964 100644 --- a/tasks/tests/unit/test_test_results_finisher.py +++ b/tasks/tests/unit/test_test_results_finisher.py @@ -26,6 +26,7 @@ from services.test_results import generate_test_id from services.urls import get_members_url from tasks.test_results_finisher import TestResultsFinisherTask +from tests.helpers import mock_all_plans_and_tiers here = Path(__file__) @@ -336,8 +337,12 @@ def test_results_setup_no_instances(mocker, dbsession): class TestUploadTestFinisherTask(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + @pytest.mark.integration - @pytest.mark.django_db(databases={"default"}) + @pytest.mark.django_db def test_upload_finisher_task_call( self, mocker, @@ -458,6 +463,7 @@ def test_upload_finisher_task_call( ) @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_no_failures( self, mocker, @@ -515,6 +521,7 @@ def test_upload_finisher_task_call_no_failures( assert expected_result == result + @pytest.mark.django_db @pytest.mark.integration def test_upload_finisher_task_call_no_success( self, @@ -576,6 +583,7 @@ def test_upload_finisher_task_call_no_success( ) @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_upgrade_comment( self, mocker, @@ -648,6 +656,7 @@ def test_upload_finisher_task_call_upgrade_comment( ) @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_existing_comment( self, mocker, @@ -773,6 +782,7 @@ def test_upload_finisher_task_call_existing_comment( assert expected_result == result @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_comment_fails( self, mocker, @@ -822,6 +832,7 @@ def test_upload_finisher_task_call_comment_fails( "fail_count,count,recent_passes_count", [(2, 15, 13), (50, 150, 10)] ) @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_with_flaky( self, mocker, @@ -932,6 +943,7 @@ def test_upload_finisher_task_call_with_flaky( ) @pytest.mark.integration + @pytest.mark.django_db def test_upload_finisher_task_call_main_branch( self, mocker, @@ -988,7 +1000,7 @@ def test_upload_finisher_task_call_main_branch( ) @pytest.mark.integration - @pytest.mark.django_db(databases={"default"}) + @pytest.mark.django_db def test_upload_finisher_task_call_computed_name( self, mocker, @@ -1105,6 +1117,7 @@ def test_upload_finisher_task_call_computed_name( ) @pytest.mark.integration + @pytest.mark.django_db @pytest.mark.parametrize("plan", ["users-basic", "users-pr-inappm"]) def test_upload_finisher_task_call_main_with_plan( self, diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 000000000..3d78a37dd --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,154 @@ +from shared.django_apps.codecov_auth.models import BillingRate +from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory +from shared.plan.constants import PlanName, PlanPrice, TierName + + +def mock_all_plans_and_tiers(): + trial_tier = TierFactory(tier_name=TierName.TRIAL.value) + PlanFactory( + tier=trial_tier, + name=PlanName.TRIAL_PLAN_NAME.value, + paid_plan=False, + marketing_name="Developer", + benefits=[ + "Configurable # of users", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + ) + + basic_tier = TierFactory(tier_name=TierName.BASIC.value) + PlanFactory( + name=PlanName.BASIC_PLAN_NAME.value, + tier=basic_tier, + marketing_name="Developer", + benefits=[ + "Up to 1 user", + "Unlimited public repositories", + "Unlimited private repositories", + ], + monthly_uploads_limit=250, + ) + PlanFactory( + name=PlanName.FREE_PLAN_NAME.value, + tier=basic_tier, + marketing_name="Developer", + benefits=[ + "Up to 1 user", + "Unlimited public repositories", + "Unlimited private repositories", + ], + ) + + pro_tier = TierFactory(tier_name=TierName.PRO.value) + PlanFactory( + name=PlanName.CODECOV_PRO_MONTHLY.value, + tier=pro_tier, + marketing_name="Pro", + benefits=[ + "Configurable # of users", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + billing_rate=BillingRate.MONTHLY.value, + base_unit_price=PlanPrice.MONTHLY.value, + paid_plan=True, + ) + PlanFactory( + name=PlanName.CODECOV_PRO_YEARLY.value, + tier=pro_tier, + marketing_name="Pro", + benefits=[ + "Configurable # of users", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + billing_rate=BillingRate.ANNUALLY.value, + base_unit_price=PlanPrice.YEARLY.value, + paid_plan=True, + ) + + team_tier = TierFactory(tier_name=TierName.TEAM.value) + PlanFactory( + name=PlanName.TEAM_MONTHLY.value, + tier=team_tier, + marketing_name="Team", + benefits=[ + "Up to 10 users", + "Unlimited repositories", + "2500 private repo uploads", + "Patch coverage analysis", + ], + billing_rate=BillingRate.MONTHLY.value, + base_unit_price=PlanPrice.TEAM_MONTHLY.value, + monthly_uploads_limit=2500, + paid_plan=True, + ) + PlanFactory( + name=PlanName.TEAM_YEARLY.value, + tier=team_tier, + marketing_name="Team", + benefits=[ + "Up to 10 users", + "Unlimited repositories", + "2500 private repo uploads", + "Patch coverage analysis", + ], + billing_rate=BillingRate.ANNUALLY.value, + base_unit_price=PlanPrice.TEAM_YEARLY.value, + monthly_uploads_limit=2500, + paid_plan=True, + ) + + sentry_tier = TierFactory(tier_name=TierName.SENTRY.value) + PlanFactory( + name=PlanName.SENTRY_MONTHLY.value, + tier=sentry_tier, + marketing_name="Sentry Pro", + billing_rate=BillingRate.MONTHLY.value, + base_unit_price=PlanPrice.MONTHLY.value, + paid_plan=True, + benefits=[ + "Includes 5 seats", + "$12 per additional seat", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + ) + PlanFactory( + name=PlanName.SENTRY_YEARLY.value, + tier=sentry_tier, + marketing_name="Sentry Pro", + billing_rate=BillingRate.ANNUALLY.value, + base_unit_price=PlanPrice.YEARLY.value, + paid_plan=True, + benefits=[ + "Includes 5 seats", + "$10 per additional seat", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + ) + + enterprise_tier = TierFactory(tier_name=TierName.ENTERPRISE.value) + PlanFactory( + name=PlanName.ENTERPRISE_CLOUD_MONTHLY.value, + tier=enterprise_tier, + marketing_name="Enterprise", + billing_rate=BillingRate.MONTHLY.value, + base_unit_price=PlanPrice.MONTHLY.value, + paid_plan=True, + ) + PlanFactory( + name=PlanName.ENTERPRISE_CLOUD_YEARLY.value, + tier=enterprise_tier, + marketing_name="Enterprise", + billing_rate=BillingRate.ANNUALLY.value, + base_unit_price=PlanPrice.YEARLY.value, + paid_plan=True, + ) From fe2f21e3a024207af0c4bc0592a506cd87980094 Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Thu, 23 Jan 2025 15:28:47 +0100 Subject: [PATCH 04/13] resolve all unit tests --- .../contexts/tests/test_comment_context.py | 5 +++ .../tests/test_commit_status_context.py | 5 +++ .../notify/messages/tests/test_comment.py | 3 ++ .../messages/tests/test_commit_status.py | 11 ++++++ .../notify/tests/test_notify_service.py | 3 ++ .../tests/test_bundle_analysis.py | 4 +++ services/test_results.py | 15 +++++--- services/tests/test_billing.py | 10 ++++++ services/tests/test_decoration.py | 34 ++++++++++++++++++- services/tests/test_seats.py | 12 +++++++ services/tests/test_test_results.py | 3 ++ tasks/tests/unit/test_new_user_activated.py | 14 ++++++++ tasks/tests/unit/test_sync_pull.py | 5 +++ tasks/tests/unit/test_ta_finisher_task.py | 3 ++ tests/helpers.py | 22 ++++++++++++ 15 files changed, 144 insertions(+), 5 deletions(-) diff --git a/services/bundle_analysis/notify/contexts/tests/test_comment_context.py b/services/bundle_analysis/notify/contexts/tests/test_comment_context.py index eb77b2415..67247e09d 100644 --- a/services/bundle_analysis/notify/contexts/tests/test_comment_context.py +++ b/services/bundle_analysis/notify/contexts/tests/test_comment_context.py @@ -22,6 +22,7 @@ ) from services.repository import EnrichedPull from services.seats import SeatActivationInfo, ShouldActivateSeat +from tests.helpers import mock_all_plans_and_tiers class TestBundleAnalysisPRCommentNotificationContext: @@ -272,7 +273,9 @@ def test_evaluate_should_use_upgrade_message( builder.evaluate_should_use_upgrade_message() assert builder._notification_context.should_use_upgrade_comment == expected + @pytest.mark.django_db def test_build_context(self, dbsession, mocker, mock_storage): + mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) repository = head_commit.repository head_commit_report, base_commit_report = get_report_pair( @@ -305,7 +308,9 @@ def test_build_context(self, dbsession, mocker, mock_storage): == head_commit_report.external_id ) + @pytest.mark.django_db def test_initialize_from_context(self, dbsession, mocker): + mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) user_yaml = UserYaml.from_dict(PATCH_CENTRIC_DEFAULT_CONFIG) builder = BundleAnalysisPRCommentContextBuilder().initialize( diff --git a/services/bundle_analysis/notify/contexts/tests/test_commit_status_context.py b/services/bundle_analysis/notify/contexts/tests/test_commit_status_context.py index afb5be30c..dc9dd06ee 100644 --- a/services/bundle_analysis/notify/contexts/tests/test_commit_status_context.py +++ b/services/bundle_analysis/notify/contexts/tests/test_commit_status_context.py @@ -25,6 +25,7 @@ from services.bundle_analysis.notify.types import NotificationUserConfig from services.repository import EnrichedPull from services.seats import SeatActivationInfo, ShouldActivateSeat +from tests.helpers import mock_all_plans_and_tiers class TestBundleAnalysisPRCommentNotificationContext: @@ -217,7 +218,9 @@ def test_load_commit_status_level( context = builder.get_result() assert context.commit_status_level == expected + @pytest.mark.django_db def test_build_context(self, dbsession, mocker, mock_storage): + mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) repository = head_commit.repository head_commit_report, base_commit_report = get_report_pair( @@ -259,7 +262,9 @@ def test_build_context(self, dbsession, mocker, mock_storage): assert context.cache_ttl == 600 assert context.commit_status_url is not None + @pytest.mark.django_db def test_initialize_from_context(self, dbsession, mocker): + mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) user_yaml = UserYaml.from_dict(PATCH_CENTRIC_DEFAULT_CONFIG) builder = CommitStatusNotificationContextBuilder().initialize( diff --git a/services/bundle_analysis/notify/messages/tests/test_comment.py b/services/bundle_analysis/notify/messages/tests/test_comment.py index f98dbcd95..1ad4e41be 100644 --- a/services/bundle_analysis/notify/messages/tests/test_comment.py +++ b/services/bundle_analysis/notify/messages/tests/test_comment.py @@ -26,10 +26,13 @@ ) from services.bundle_analysis.notify.types import NotificationUserConfig from services.notification.notifiers.base import NotificationResult +from tests.helpers import mock_all_plans_and_tiers class TestCommentMesage: + @pytest.mark.django_db def test_build_message_from_samples(self, dbsession, mocker, mock_storage): + mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) repository = head_commit.repository head_commit_report, base_commit_report = get_report_pair( diff --git a/services/bundle_analysis/notify/messages/tests/test_commit_status.py b/services/bundle_analysis/notify/messages/tests/test_commit_status.py index 3df389fbc..e1799b5a7 100644 --- a/services/bundle_analysis/notify/messages/tests/test_commit_status.py +++ b/services/bundle_analysis/notify/messages/tests/test_commit_status.py @@ -24,6 +24,7 @@ ) from services.notification.notifiers.base import NotificationResult from services.seats import SeatActivationInfo, ShouldActivateSeat +from tests.helpers import mock_all_plans_and_tiers class FakeRedis(object): @@ -55,6 +56,10 @@ def mock_cache(mocker): class TestCommitStatusMessage: + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + @pytest.mark.parametrize( "user_config, expected", [ @@ -81,6 +86,7 @@ class TestCommitStatusMessage: ), ], ) + @pytest.mark.django_db def test_build_message_from_samples_negative_changes( self, user_config, expected, dbsession, mocker, mock_storage ): @@ -133,6 +139,7 @@ def test_build_message_from_samples_negative_changes( ), ], ) + @pytest.mark.django_db def test_build_message_from_samples( self, user_config, expected, dbsession, mocker, mock_storage ): @@ -159,6 +166,7 @@ def test_build_message_from_samples( message = CommitStatusMessageStrategy().build_message(context) assert message == expected + @pytest.mark.django_db def _setup_send_message_tests( self, dbsession, mocker, torngit_ghapp_data, mock_storage ): @@ -207,6 +215,7 @@ def _setup_send_message_tests( "Passed with Warnings - Bundle change: 95.64% (Threshold: 5.0%)", ) + @pytest.mark.django_db @pytest.mark.parametrize( "torngit_ghapp_data", [ @@ -246,6 +255,7 @@ def test_send_message_success( # Side effect of sending message is updating the cache assert mock_cache.get_backend().get(strategy._cache_key(context)) == message + @pytest.mark.django_db def test_send_message_fail(self, dbsession, mocker, mock_storage): fake_repo_provider, context, message = self._setup_send_message_tests( dbsession, mocker, None, mock_storage @@ -259,6 +269,7 @@ def test_send_message_fail(self, dbsession, mocker, mock_storage): explanation="TorngitClientError", ) + @pytest.mark.django_db def test_skip_payload_unchanged(self, dbsession, mocker, mock_storage, mock_cache): fake_repo_provider, context, message = self._setup_send_message_tests( dbsession, mocker, None, mock_storage diff --git a/services/bundle_analysis/notify/tests/test_notify_service.py b/services/bundle_analysis/notify/tests/test_notify_service.py index 0a9299768..6a1155e11 100644 --- a/services/bundle_analysis/notify/tests/test_notify_service.py +++ b/services/bundle_analysis/notify/tests/test_notify_service.py @@ -29,6 +29,7 @@ ) from services.bundle_analysis.notify.types import NotificationType from services.notification.notifiers.base import NotificationResult +from tests.helpers import mock_all_plans_and_tiers def override_comment_builder_and_message_strategy(mocker): @@ -114,7 +115,9 @@ def test_build_base_context(self, mocker, dbsession, mock_storage): assert base_context.commit_report == head_commit_report assert base_context.bundle_analysis_report.session_count() == 19 + @pytest.mark.django_db def test_create_context_success(self, dbsession, mock_storage, mocker): + mock_all_plans_and_tiers() current_yaml = UserYaml.from_dict(PATCH_CENTRIC_DEFAULT_CONFIG) head_commit, base_commit = get_commit_pair(dbsession) head_commit_report, base_commit_report = get_report_pair( diff --git a/services/bundle_analysis/tests/test_bundle_analysis.py b/services/bundle_analysis/tests/test_bundle_analysis.py index f5481bdd8..041a0f47c 100644 --- a/services/bundle_analysis/tests/test_bundle_analysis.py +++ b/services/bundle_analysis/tests/test_bundle_analysis.py @@ -24,6 +24,7 @@ ) from services.repository import EnrichedPull from services.urls import get_bundle_analysis_pull_url +from tests.helpers import mock_all_plans_and_tiers class MockBundleReport: @@ -57,6 +58,7 @@ def hook_mock_pull(mocker, mock_pull): mocker.patch(usage, return_value=mock_pull) +@pytest.mark.django_db @pytest.mark.parametrize( "bundle_changes, bundle_routes_changes, percent_change, user_config, expected_message", [ @@ -396,6 +398,7 @@ def test_bundle_analysis_notify( mock_storage, mock_repo_provider, ): + mock_all_plans_and_tiers() hook_mock_repo_provider(mocker, mock_repo_provider) base_commit = CommitFactory() dbsession.add(base_commit) @@ -517,6 +520,7 @@ def test_bundle_analysis_notify( ) +@pytest.mark.django_db @pytest.mark.asyncio async def test_bundle_analysis_save_measurements_report_size( dbsession, mocker, mock_storage diff --git a/services/test_results.py b/services/test_results.py index 7b4727d08..0cd82aa69 100644 --- a/services/test_results.py +++ b/services/test_results.py @@ -451,12 +451,11 @@ def get_test_summary_for_commit( def not_private_and_free_or_team(repo: Repository): plan = Plan.objects.get(name=repo.owner.plan) + return not ( repo.private - and ( - plan.tier.tier_name != TierName.BASIC.value - and plan.tier.tier_name != TierName.TEAM.value - ) + and plan + and plan.tier.tier_name in {TierName.BASIC.value, TierName.TEAM.value} ) @@ -468,6 +467,14 @@ def should_do_flaky_detection(repo: Repository, commit_yaml: UserYaml) -> bool: identifier=repo.repoid, default=True ) has_valid_plan_repo_or_owner = not_private_and_free_or_team(repo) + print( + "has_flaky_configured", + has_flaky_configured, + "feature_enabled", + feature_enabled, + "has_valid_plan_repo_or_owner", + has_valid_plan_repo_or_owner, + ) return has_flaky_configured and (feature_enabled or has_valid_plan_repo_or_owner) diff --git a/services/tests/test_billing.py b/services/tests/test_billing.py index f4fe367f5..7a20a2b0b 100644 --- a/services/tests/test_billing.py +++ b/services/tests/test_billing.py @@ -1,8 +1,10 @@ +import pytest from django.test import override_settings from shared.plan.constants import PlanName from shared.plan.service import PlanService from database.tests.factories import OwnerFactory +from tests.helpers import mock_all_plans_and_tiers class TestBillingServiceTestCase(object): @@ -10,6 +12,11 @@ class TestBillingServiceTestCase(object): BillingService is deprecated - use PlanService instead. """ + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_pr_author_plan_check(self, request, dbsession, with_sql_functions): owner = OwnerFactory.create(service="github", plan="users-pr-inappm") dbsession.add(owner) @@ -17,6 +24,7 @@ def test_pr_author_plan_check(self, request, dbsession, with_sql_functions): plan = PlanService(owner) assert plan.is_pr_billing_plan + @pytest.mark.django_db @override_settings(IS_ENTERPRISE=True) def test_pr_author_enterprise_plan_check( self, request, dbsession, mock_configuration, with_sql_functions @@ -35,6 +43,7 @@ def test_pr_author_enterprise_plan_check( assert plan.is_pr_billing_plan + @pytest.mark.django_db def test_plan_not_pr_author(self, request, dbsession, with_sql_functions): owner = OwnerFactory.create( service="github", plan=PlanName.CODECOV_PRO_MONTHLY_LEGACY.value @@ -46,6 +55,7 @@ def test_plan_not_pr_author(self, request, dbsession, with_sql_functions): assert not plan.is_pr_billing_plan + @pytest.mark.django_db @override_settings(IS_ENTERPRISE=True) def test_pr_author_enterprise_plan_check_non_pr_plan( self, request, dbsession, mocker, mock_configuration, with_sql_functions diff --git a/services/tests/test_decoration.py b/services/tests/test_decoration.py index daef67d9e..1bd980896 100644 --- a/services/tests/test_decoration.py +++ b/services/tests/test_decoration.py @@ -35,6 +35,7 @@ determine_uploads_used, ) from services.repository import EnrichedPull +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -211,6 +212,10 @@ def gitlab_enriched_pull_root(dbsession, gitlab_root_group): class TestDecorationServiceTestCase(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + @pytest.mark.django_db def test_decoration_type_basic_plan_upload_limit( self, enriched_pull, dbsession, mocker @@ -452,6 +457,7 @@ def test_uploads_used_with_expired_trial(self, mocker): assert uploads_used == 2 + @pytest.mark.django_db def test_get_decoration_type_no_pull(self, mocker): decoration_details = determine_decoration_details(None) @@ -459,6 +465,7 @@ def test_get_decoration_type_no_pull(self, mocker): assert decoration_details.reason == "No pull" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_no_provider_pull(self, mocker, enriched_pull): enriched_pull.provider_pull = None @@ -471,6 +478,7 @@ def test_get_decoration_type_no_provider_pull(self, mocker, enriched_pull): ) assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_public_repo(self, dbsession, mocker, enriched_pull): enriched_pull.database_pull.repository.private = False dbsession.flush() @@ -481,6 +489,7 @@ def test_get_decoration_type_public_repo(self, dbsession, mocker, enriched_pull) assert decoration_details.reason == "Public repo" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_not_pr_plan(self, dbsession, mocker, enriched_pull): enriched_pull.database_pull.repository.owner.plan = "users-inappm" dbsession.flush() @@ -491,12 +500,14 @@ def test_get_decoration_type_not_pr_plan(self, dbsession, mocker, enriched_pull) assert decoration_details.reason == "Org not on PR plan" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db + # what is a users plan? def test_get_decoration_type_for_users_plan(self, dbsession): repository = RepositoryFactory.create( owner__username="drazisil-org", owner__service="github", owner__unencrypted_oauth_token="testtfasdfasdflxuu2kfer2ef23", - owner__plan="users", + owner__plan=PlanName.BASIC_PLAN_NAME.value, private=True, ) dbsession.add(repository) @@ -558,6 +569,7 @@ def test_get_decoration_type_for_users_plan(self, dbsession): not in enriched_pull_whitelisted.database_pull.repository.owner.plan_activated_users ) + @pytest.mark.django_db def test_get_decoration_type_pr_author_not_in_db(self, mocker, enriched_pull): enriched_pull.provider_pull["author"]["id"] = "190" @@ -567,6 +579,7 @@ def test_get_decoration_type_pr_author_not_in_db(self, mocker, enriched_pull): assert decoration_details.reason == "PR author not found in database" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_pr_author_manual_activation_required( self, dbsession, mocker, enriched_pull, with_sql_functions ): @@ -593,6 +606,7 @@ def test_get_decoration_type_pr_author_manual_activation_required( not in enriched_pull.database_pull.repository.owner.plan_activated_users ) + @pytest.mark.django_db @pytest.mark.parametrize( "is_bot,param,value", [ @@ -612,6 +626,7 @@ def test_is_bot_account(self, is_bot, param, value): pr_author.service_id = value assert _is_bot_account(pr_author) == is_bot + @pytest.mark.django_db def test_get_decoration_type_bot(self, dbsession, mocker, enriched_pull): pr_author = OwnerFactory.create( service="github", @@ -632,6 +647,7 @@ def test_get_decoration_type_bot(self, dbsession, mocker, enriched_pull): ) assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_pr_author_already_active( self, dbsession, mocker, enriched_pull ): @@ -656,6 +672,7 @@ def test_get_decoration_type_pr_author_already_active( assert decoration_details.reason == "User is currently activated" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_should_attempt_pr_author_auto_activation( self, dbsession, mocker, enriched_pull ): @@ -688,6 +705,7 @@ def test_get_decoration_type_should_attempt_pr_author_auto_activation( not in enriched_pull.database_pull.repository.owner.plan_activated_users ) + @pytest.mark.django_db def test_get_decoration_type_should_attempt_pr_author_auto_activation_users_free( self, dbsession, mocker, enriched_pull ): @@ -721,6 +739,7 @@ def test_get_decoration_type_should_attempt_pr_author_auto_activation_users_free not in enriched_pull.database_pull.repository.owner.plan_activated_users ) + @pytest.mark.django_db def test_get_decoration_type_passing_empty_upload( self, dbsession, mocker, enriched_pull ): @@ -733,6 +752,7 @@ def test_get_decoration_type_passing_empty_upload( assert decoration_details.reason == "Non testable files got changed." assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_failing_empty_upload( self, dbsession, mocker, enriched_pull ): @@ -745,6 +765,7 @@ def test_get_decoration_type_failing_empty_upload( assert decoration_details.reason == "Testable files got changed." assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_processing_upload( self, dbsession, mocker, enriched_pull ): @@ -759,6 +780,11 @@ def test_get_decoration_type_processing_upload( class TestDecorationServiceGitLabTestCase(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_get_decoration_type_not_pr_plan_gitlab_subgroup( self, dbsession, @@ -776,6 +802,7 @@ def test_get_decoration_type_not_pr_plan_gitlab_subgroup( assert decoration_details.reason == "Org not on PR plan" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_pr_author_not_in_db_gitlab_subgroup( self, mocker, @@ -791,6 +818,7 @@ def test_get_decoration_type_pr_author_not_in_db_gitlab_subgroup( assert decoration_details.reason == "PR author not found in database" assert decoration_details.should_attempt_author_auto_activation is False + @pytest.mark.django_db def test_get_decoration_type_pr_author_manual_activation_required_gitlab_subgroup( self, dbsession, @@ -836,6 +864,7 @@ def test_get_decoration_type_pr_author_manual_activation_required_gitlab_subgrou # activation hasn't happened yet assert pr_author.ownerid not in gitlab_root_group.plan_activated_users + @pytest.mark.django_db def test_get_decoration_type_pr_author_already_active_subgroup( self, dbsession, @@ -864,6 +893,7 @@ def test_get_decoration_type_pr_author_already_active_subgroup( assert decoration_details.activation_org_ownerid is None assert decoration_details.activation_author_ownerid is None + @pytest.mark.django_db def test_get_decoration_type_should_attempt_pr_author_auto_activation( self, dbsession, @@ -895,6 +925,7 @@ def test_get_decoration_type_should_attempt_pr_author_auto_activation( # activation hasn't happened yet assert pr_author.ownerid not in gitlab_root_group.plan_activated_users + @pytest.mark.django_db def test_get_decoration_type_owner_activated_users_null( self, dbsession, mocker, enriched_pull ): @@ -956,6 +987,7 @@ def test_uploads_used_with_expired_trial(self, mocker, dbsession): assert uploads_used == 0 + @pytest.mark.django_db def test_author_is_activated_on_subgroup_not_root( self, dbsession, gitlab_root_group, gitlab_enriched_pull_subgroup ): diff --git a/services/tests/test_seats.py b/services/tests/test_seats.py index 8b1eb851a..bfc10e4c1 100644 --- a/services/tests/test_seats.py +++ b/services/tests/test_seats.py @@ -1,8 +1,10 @@ +import pytest from shared.billing import BillingPlan from database.tests.factories import OwnerFactory, PullFactory from services.repository import EnrichedPull from services.seats import ShouldActivateSeat, determine_seat_activation +from tests.helpers import mock_all_plans_and_tiers def test_seat_provider_none(dbsession): @@ -41,7 +43,9 @@ def test_seat_repo_public(dbsession): assert activate_seat_info.reason == "public_repo" +@pytest.mark.django_db def test_seat_billing_plan(dbsession): + mock_all_plans_and_tiers() pull = PullFactory() dbsession.add(pull) dbsession.flush() @@ -60,7 +64,9 @@ def test_seat_billing_plan(dbsession): assert activate_seat_info.reason == "no_pr_billing_plan" +@pytest.mark.django_db def test_seat_no_author(dbsession): + mock_all_plans_and_tiers() pull = PullFactory() dbsession.add(pull) dbsession.flush() @@ -79,7 +85,9 @@ def test_seat_no_author(dbsession): assert activate_seat_info.reason == "no_pr_author" +@pytest.mark.django_db def test_seat_author_in_org(dbsession): + mock_all_plans_and_tiers() pull = PullFactory() dbsession.add(pull) dbsession.flush() @@ -106,7 +114,9 @@ def test_seat_author_in_org(dbsession): assert activate_seat_info.reason == "author_in_plan_activated_users" +@pytest.mark.django_db def test_seat_author_not_in_org(dbsession): + mock_all_plans_and_tiers() pull = PullFactory() dbsession.add(pull) dbsession.flush() @@ -130,7 +140,9 @@ def test_seat_author_not_in_org(dbsession): assert activate_seat_info.reason == "manual_activate" +@pytest.mark.django_db def test_seat_author_auto_activate(dbsession): + mock_all_plans_and_tiers() pull = PullFactory() dbsession.add(pull) dbsession.flush() diff --git a/services/tests/test_test_results.py b/services/tests/test_test_results.py index 0d5ab6b6b..e1aeb1223 100644 --- a/services/tests/test_test_results.py +++ b/services/tests/test_test_results.py @@ -23,6 +23,7 @@ ) from services.urls import services_short_dict from services.yaml import UserYaml +from tests.helpers import mock_all_plans_and_tiers def mock_repo_service(): @@ -250,6 +251,7 @@ def test_notify_fail_no_pull( assert notification_result == NotifierResult.NO_PULL +@pytest.mark.django_db @pytest.mark.parametrize( "config,feature_flag,private,plan,ex_result", [ @@ -264,6 +266,7 @@ def test_notify_fail_no_pull( def test_should_do_flake_detection( dbsession, mocker, config, feature_flag, private, plan, ex_result ): + mock_all_plans_and_tiers() owner = OwnerFactory(plan=plan) repo = RepositoryFactory(private=private, owner=owner) dbsession.add(repo) diff --git a/tasks/tests/unit/test_new_user_activated.py b/tasks/tests/unit/test_new_user_activated.py index 4d7becf0d..3bd3fdeb2 100644 --- a/tasks/tests/unit/test_new_user_activated.py +++ b/tasks/tests/unit/test_new_user_activated.py @@ -11,6 +11,7 @@ RepositoryFactory, ) from tasks.new_user_activated import NewUserActivatedTask +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -44,6 +45,11 @@ def pull(dbsession): class TestNewUserActivatedTaskUnit(object): + @pytest.fixture(autouse=True) + def mock_all_plans_and_tiers(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_get_pulls_authored_by_user_none(self, dbsession, pull): org_ownerid = pull.repository.ownerid user_ownerid_with_no_pulls = 12312412 @@ -52,6 +58,7 @@ def test_get_pulls_authored_by_user_none(self, dbsession, pull): ) assert res == [] + @pytest.mark.django_db def test_get_pulls_authored_by_user(self, dbsession, pull): pull_by_other_author = PullFactory.create( repository=pull.repository, @@ -72,6 +79,7 @@ def test_get_pulls_authored_by_user(self, dbsession, pull): assert authored_pull.state == "open" assert authored_pull.author.ownerid == user_ownerid + @pytest.mark.django_db def test_is_org_on_pr_plan_gitlab_subgroup(self, dbsession, with_sql_functions): root_group = OwnerFactory.create( username="root_group", @@ -94,6 +102,7 @@ def test_is_org_on_pr_plan_gitlab_subgroup(self, dbsession, with_sql_functions): res = NewUserActivatedTask().is_org_on_pr_plan(dbsession, subgroup.ownerid) assert res is True + @pytest.mark.django_db def test_org_not_found(self, mocker, dbsession): unknown_org_ownerid = 404123 user_ownerid = 123 @@ -106,6 +115,7 @@ def test_org_not_found(self, mocker, dbsession): "reason": "org not on pr author billing plan", } + @pytest.mark.django_db def test_org_not_on_pr_plan(self, mocker, dbsession, pull): pull.repository.owner.plan = "users-inappm" dbsession.flush() @@ -118,6 +128,7 @@ def test_org_not_on_pr_plan(self, mocker, dbsession, pull): "reason": "org not on pr author billing plan", } + @pytest.mark.django_db def test_no_commit_notifications_found(self, mocker, dbsession, pull): mocked_possibly_resend_notifications = mocker.patch( "tasks.new_user_activated.NewUserActivatedTask.possibly_resend_notifications" @@ -132,6 +143,7 @@ def test_no_commit_notifications_found(self, mocker, dbsession, pull): } assert not mocked_possibly_resend_notifications.called + @pytest.mark.django_db def test_no_head_commit_on_pull(self, mocker, dbsession, pull): pull.head = None mocked_possibly_resend_notifications = mocker.patch( @@ -147,6 +159,7 @@ def test_no_head_commit_on_pull(self, mocker, dbsession, pull): } assert not mocked_possibly_resend_notifications.called + @pytest.mark.django_db def test_commit_notifications_all_standard(self, mocker, dbsession, pull): pull_head_commit = pull.get_head_commit() cn1 = CommitNotificationFactory.create( @@ -174,6 +187,7 @@ def test_commit_notifications_all_standard(self, mocker, dbsession, pull): "reason": "no pulls/pull notifications met criteria", } + @pytest.mark.django_db def test_commit_notifications_resend_single_pull(self, mocker, dbsession, pull): pull_head_commit = pull.get_head_commit() cn1 = CommitNotificationFactory.create( diff --git a/tasks/tests/unit/test_sync_pull.py b/tasks/tests/unit/test_sync_pull.py index 9492854ed..13dca0661 100644 --- a/tasks/tests/unit/test_sync_pull.py +++ b/tasks/tests/unit/test_sync_pull.py @@ -16,6 +16,7 @@ from services.repository import EnrichedPull from services.yaml import UserYaml from tasks.sync_pull import PullSyncTask +from tests.helpers import mock_all_plans_and_tiers here = Path(__file__) @@ -60,6 +61,7 @@ def pull(dbsession, repository, base_commit, head_commit) -> Pull: "tests_exist", [True, False], ) +@pytest.mark.django_db def test_update_pull_commits_merged( dbsession, mocker, @@ -69,6 +71,7 @@ def test_update_pull_commits_merged( base_commit, pull, ): + mock_all_plans_and_tiers() mock_feature = mocker.patch("services.test_results.FLAKY_TEST_DETECTION") mock_feature.check_value.return_value = True @@ -512,7 +515,9 @@ def test_trigger_ai_pr_review( @pytest.mark.parametrize("flake_detection", [False, True]) +@pytest.mark.django_db def test_trigger_process_flakes(dbsession, mocker, flake_detection, repository): + mock_all_plans_and_tiers() current_yaml = UserYaml.from_dict(dict()) mock_feature = mocker.patch("services.test_results.FLAKY_TEST_DETECTION") mock_feature.check_value.return_value = True diff --git a/tasks/tests/unit/test_ta_finisher_task.py b/tasks/tests/unit/test_ta_finisher_task.py index e4464bdee..cb4e12c21 100644 --- a/tasks/tests/unit/test_ta_finisher_task.py +++ b/tasks/tests/unit/test_ta_finisher_task.py @@ -21,6 +21,7 @@ from services.urls import services_short_dict from tasks.ta_finisher import TAFinisherTask from tasks.ta_processor import TAProcessorTask +from tests.helpers import mock_all_plans_and_tiers here = Path(__file__) @@ -98,6 +99,7 @@ def generate_junit_xml( @travel("2025-01-01T00:00:00Z", tick=False) +@pytest.mark.django_db def test_test_analytics( dbsession, mocker, @@ -106,6 +108,7 @@ def test_test_analytics( snapshot, mock_repo_provider_comments, ): + mock_all_plans_and_tiers() url = "literally/whatever" testruns = [ diff --git a/tests/helpers.py b/tests/helpers.py index 3d78a37dd..56d82d6b8 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -70,6 +70,28 @@ def mock_all_plans_and_tiers(): base_unit_price=PlanPrice.YEARLY.value, paid_plan=True, ) + PlanFactory( + name=PlanName.CODECOV_PRO_MONTHLY_LEGACY.value, + tier=pro_tier, + marketing_name="Pro", + benefits=[ + "Configurable # of users", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + ) + PlanFactory( + name=PlanName.CODECOV_PRO_YEARLY_LEGACY.value, + tier=pro_tier, + marketing_name="Pro", + benefits=[ + "Configurable # of users", + "Unlimited public repositories", + "Unlimited private repositories", + "Priority Support", + ], + ) team_tier = TierFactory(tier_name=TierName.TEAM.value) PlanFactory( From 0a938c642d5c8cd73d9acd7a7e943bd7e26305a6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 23 Jan 2025 09:52:17 -0800 Subject: [PATCH 05/13] get rid of prints --- .../comparison/tests/unit/overlay/test_critical_path.py | 2 -- services/notification/notifiers/tests/unit/test_slack.py | 2 -- .../path_fixer/tests/unit/test_user_path_includes.py | 1 - services/report/tests/unit/test_sessions.py | 5 ----- services/test_results.py | 9 +-------- services/tests/test_test_results.py | 1 - tasks/tests/unit/test_brolly_stats_rollup.py | 1 - tasks/tests/unit/test_notify_error_task.py | 1 - tasks/tests/unit/test_profiling_collection.py | 3 --- tasks/tests/unit/test_profiling_normalizer.py | 1 - tasks/tests/unit/test_sync_teams_task.py | 3 --- tasks/tests/unit/test_test_results_processor_task.py | 1 - tasks/upload.py | 1 - 13 files changed, 1 insertion(+), 30 deletions(-) diff --git a/services/comparison/tests/unit/overlay/test_critical_path.py b/services/comparison/tests/unit/overlay/test_critical_path.py index b78fb26c5..6ce9d5e2b 100644 --- a/services/comparison/tests/unit/overlay/test_critical_path.py +++ b/services/comparison/tests/unit/overlay/test_critical_path.py @@ -274,8 +274,6 @@ def test_find_impacted_endpoints( } mock_storage.write_file("bucket", url, sample_open_telemetry_collected_as_str) a = CriticalPathOverlay(sample_comparison, None) - print(sample_comparison.head.report.files) - print(sample_comparison.head.report.files) res = a.find_impacted_endpoints() assert res == [ { diff --git a/services/notification/notifiers/tests/unit/test_slack.py b/services/notification/notifiers/tests/unit/test_slack.py index d1c36f56d..68e1af167 100644 --- a/services/notification/notifiers/tests/unit/test_slack.py +++ b/services/notification/notifiers/tests/unit/test_slack.py @@ -25,7 +25,6 @@ def test_build_payload_without_attachments( "author_name": "Codecov", "text": text, } - print(result["text"]) assert result == expected_result def test_build_payload_with_attachments( @@ -83,7 +82,6 @@ def test_build_payload_with_message( "author_name": "Codecov", "text": "This is a sample", } - print(result["text"]) assert result == expected_result def test_build_payload_without_pull( diff --git a/services/path_fixer/tests/unit/test_user_path_includes.py b/services/path_fixer/tests/unit/test_user_path_includes.py index 4e9f58933..23bb013b8 100644 --- a/services/path_fixer/tests/unit/test_user_path_includes.py +++ b/services/path_fixer/tests/unit/test_user_path_includes.py @@ -18,7 +18,6 @@ def test_user_path_fixes_star(self): def test_user_path_regex(self): path_patterns = ["sample/[^/]+/to/.*"] upi = UserPathIncludes(path_patterns) - print(upi.includes) assert upi("sample/path/to/file.go") assert upi("sample/something/to/haha.cpp") assert not upi("any/to/file.cpp") diff --git a/services/report/tests/unit/test_sessions.py b/services/report/tests/unit/test_sessions.py index 0beacdb52..b7489ea74 100644 --- a/services/report/tests/unit/test_sessions.py +++ b/services/report/tests/unit/test_sessions.py @@ -66,7 +66,6 @@ def sample_first_report(self): second_file = EditableReportFile("second_file.py") first_report.append(first_file) first_report.append(second_file) - # print(self.convert_report_to_better_readable(first_report)["archive"]) assert self.convert_report_to_better_readable(first_report)["archive"] == { "first_file.py": [ ( @@ -241,7 +240,6 @@ def test_adjust_sessions_full_cf_only(self, sample_first_report): assert clear_carryforward_sessions( sample_first_report, second_report, ["enterprise"], current_yaml ) == SessionAdjustmentResult([0], []) - print(self.convert_report_to_better_readable(sample_first_report)) assert self.convert_report_to_better_readable(sample_first_report) == { "archive": { "first_file.py": [ @@ -515,7 +513,6 @@ def test_adjust_sessions_partial_cf_only_some_changes(self, sample_first_report) assert clear_carryforward_sessions( sample_first_report, second_report, ["enterprise"], current_yaml ) == SessionAdjustmentResult([], [0]) - print(self.convert_report_to_better_readable(sample_first_report)) assert self.convert_report_to_better_readable(sample_first_report) == { "archive": { "first_file.py": [ @@ -763,7 +760,6 @@ def test_adjust_sessions_partial_cf_only_full_deletion_due_to_lost_labels( sample_first_report, second_report, ["enterprise"], current_yaml ) == SessionAdjustmentResult([0], []) res = self.convert_report_to_better_readable(sample_first_report) - # print(res["report"]["sessions"]) assert res["report"]["sessions"] == { "1": { "t": None, @@ -811,7 +807,6 @@ def test_adjust_sessions_partial_cf_only_full_deletion_due_to_lost_labels( "se": {}, }, } - print(self.convert_report_to_better_readable(sample_first_report)["archive"]) assert self.convert_report_to_better_readable(sample_first_report)[ "archive" ] == { diff --git a/services/test_results.py b/services/test_results.py index 0cd82aa69..e33c10388 100644 --- a/services/test_results.py +++ b/services/test_results.py @@ -467,14 +467,7 @@ def should_do_flaky_detection(repo: Repository, commit_yaml: UserYaml) -> bool: identifier=repo.repoid, default=True ) has_valid_plan_repo_or_owner = not_private_and_free_or_team(repo) - print( - "has_flaky_configured", - has_flaky_configured, - "feature_enabled", - feature_enabled, - "has_valid_plan_repo_or_owner", - has_valid_plan_repo_or_owner, - ) + return has_flaky_configured and (feature_enabled or has_valid_plan_repo_or_owner) diff --git a/services/tests/test_test_results.py b/services/tests/test_test_results.py index e1aeb1223..63ed6acb9 100644 --- a/services/tests/test_test_results.py +++ b/services/tests/test_test_results.py @@ -310,7 +310,6 @@ def test_specific_error_message(mocker): """ assert result == (True, "comment_posted") - print(mock_repo_service.mock_calls) mock_repo_service.edit_comment.assert_called_with( tn._pull.database_pull.pullid, tn._pull.database_pull.commentid, expected ) diff --git a/tasks/tests/unit/test_brolly_stats_rollup.py b/tasks/tests/unit/test_brolly_stats_rollup.py index af8ccaf74..65293e7ba 100644 --- a/tasks/tests/unit/test_brolly_stats_rollup.py +++ b/tasks/tests/unit/test_brolly_stats_rollup.py @@ -109,7 +109,6 @@ def test_run_cron_task_http_ok(self, dbsession, install_id, version): install_id_val = dbsession.query(Constants).get("install_id").value version_val = dbsession.query(Constants).get("version").value - print("mattmatt", install_id_val, version_val) mock_request = respx.post(DEFAULT_BROLLY_ENDPOINT).mock( return_value=httpx.Response(200) diff --git a/tasks/tests/unit/test_notify_error_task.py b/tasks/tests/unit/test_notify_error_task.py index c0a367bcd..fdea541b2 100644 --- a/tasks/tests/unit/test_notify_error_task.py +++ b/tasks/tests/unit/test_notify_error_task.py @@ -105,5 +105,4 @@ def test_notify_error_task_failure(mocker, dbsession, mock_repo_provider_comment repoid=commit.repoid, current_yaml={}, ) - print(result) assert result["success"] == False diff --git a/tasks/tests/unit/test_profiling_collection.py b/tasks/tests/unit/test_profiling_collection.py index 60e51cef6..6ca00cf1a 100644 --- a/tasks/tests/unit/test_profiling_collection.py +++ b/tasks/tests/unit/test_profiling_collection.py @@ -122,7 +122,6 @@ def test_run_impl_simple_run_no_existing_data_sample_new_uploads( task = ProfilingCollectionTask() res = task.run_impl(dbsession, profiling_id=pcf.id) assert res["successful"] - print(mock_storage.read_file("bucket", res["location"]).decode()) assert ( json.loads(mock_storage.read_file("bucket", res["location"]).decode()) == sample_open_telemetry_collected @@ -262,7 +261,6 @@ def test_join_profiling_uploads_with_existing_data_and_new_uploads( dbsession.add(pu) dbsession.flush() res = task.join_profiling_uploads(pcf, [pu]) - print(res) assert res == { "groups": [ { @@ -486,7 +484,6 @@ def test_merge_into_upload_file_old_result(self, dbsession, mock_storage, mocker existing_result = {"files": []} res = task.merge_into(archive_service, existing_result, [pu]) assert res is None - print(existing_result) assert existing_result == { "files": [ {"filename": "apple.py", "ln_ex_ct": [(2, 10), (101, 11)]}, diff --git a/tasks/tests/unit/test_profiling_normalizer.py b/tasks/tests/unit/test_profiling_normalizer.py index d266db36b..d525fa3f1 100644 --- a/tasks/tests/unit/test_profiling_normalizer.py +++ b/tasks/tests/unit/test_profiling_normalizer.py @@ -49,7 +49,6 @@ def test_run_impl_simple_normalizing_run( res = task.run_impl(dbsession, profiling_upload_id=puf.id) assert res["successful"] result = json.loads(mock_storage.read_file("bucket", res["location"]).decode()) - print(mock_storage.read_file("bucket", res["location"]).decode()) assert result == sample_open_telemetry_normalized diff --git a/tasks/tests/unit/test_sync_teams_task.py b/tasks/tests/unit/test_sync_teams_task.py index 33e6ed37f..8b7056e33 100644 --- a/tasks/tests/unit/test_sync_teams_task.py +++ b/tasks/tests/unit/test_sync_teams_task.py @@ -78,9 +78,6 @@ def test_gitlab_subgroups( import logging caplog.set_level(logging.DEBUG) - print(codecov_vcr) - print(dir(codecov_vcr)) - print(codecov_vcr.rewound) token = "testenll80qbqhofao65" user = OwnerFactory.create( organizations=[], service="gitlab", unencrypted_oauth_token=token diff --git a/tasks/tests/unit/test_test_results_processor_task.py b/tasks/tests/unit/test_test_results_processor_task.py index 7461e0723..41b2d018e 100644 --- a/tasks/tests/unit/test_test_results_processor_task.py +++ b/tasks/tests/unit/test_test_results_processor_task.py @@ -150,7 +150,6 @@ def test_test_result_processor_task_error_parsing_file( arguments_list=redis_queue, ) - print(caplog.text) assert "Error parsing file" in caplog.text assert result == False diff --git a/tasks/upload.py b/tasks/upload.py index 14554f5e0..e7ba9e15a 100644 --- a/tasks/upload.py +++ b/tasks/upload.py @@ -531,7 +531,6 @@ def run_impl_within_lock( # Bulk insert coverage measurements if measurements: - print("test - I am here!", measurements) self._bulk_insert_coverage_measurements(measurements=measurements) if argument_list: From 9fdf81c2e8f2944d043a782ca7d8944c4b14a911 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 23 Jan 2025 10:17:32 -0800 Subject: [PATCH 06/13] prefetch tier when needed --- .../bundle_analysis/notify/messages/tests/test_comment.py | 1 - services/notification/__init__.py | 4 ++-- services/test_results.py | 2 +- services/tests/test_test_results.py | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services/bundle_analysis/notify/messages/tests/test_comment.py b/services/bundle_analysis/notify/messages/tests/test_comment.py index 1ad4e41be..a2c7dbcdd 100644 --- a/services/bundle_analysis/notify/messages/tests/test_comment.py +++ b/services/bundle_analysis/notify/messages/tests/test_comment.py @@ -30,7 +30,6 @@ class TestCommentMesage: - @pytest.mark.django_db def test_build_message_from_samples(self, dbsession, mocker, mock_storage): mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) diff --git a/services/notification/__init__.py b/services/notification/__init__.py index 778bc9a9c..63bd6c307 100644 --- a/services/notification/__init__.py +++ b/services/notification/__init__.py @@ -67,7 +67,7 @@ def __init__( def _should_use_status_notifier(self, status_type: StatusType) -> bool: owner: Owner = self.repository.owner - plan = Plan.objects.get(name=owner.plan) + plan = Plan.objects.select_related("tier").get(name=owner.plan) if ( plan.tier.tier_name == TierName.TEAM.value @@ -86,7 +86,7 @@ def _should_use_checks_notifier(self, status_type: StatusType) -> bool: if owner.service not in ["github", "github_enterprise"]: return False - plan = Plan.objects.get(name=owner.plan) + plan = Plan.objects.select_related("tier").get(name=owner.plan) if ( plan.tier.tier_name == TierName.TEAM.value diff --git a/services/test_results.py b/services/test_results.py index e33c10388..e176dc1a4 100644 --- a/services/test_results.py +++ b/services/test_results.py @@ -450,7 +450,7 @@ def get_test_summary_for_commit( def not_private_and_free_or_team(repo: Repository): - plan = Plan.objects.get(name=repo.owner.plan) + plan = Plan.objects.select_related("tier").get(name=repo.owner.plan) return not ( repo.private diff --git a/services/tests/test_test_results.py b/services/tests/test_test_results.py index 63ed6acb9..e7b322233 100644 --- a/services/tests/test_test_results.py +++ b/services/tests/test_test_results.py @@ -330,7 +330,6 @@ def test_specific_error_message_no_error(mocker): expected = """:x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.""" assert result == (True, "comment_posted") - print(mock_repo_service.mock_calls) mock_repo_service.edit_comment.assert_called_with( tn._pull.database_pull.pullid, tn._pull.database_pull.commentid, expected ) From cdc672e4e2ba8becbca15bcdacb66e69b6c3c5ae Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Mon, 27 Jan 2025 13:22:31 +0100 Subject: [PATCH 07/13] update to not use @patch(services.notification.Plan.objects.get) --- .../tests/unit/test_notification_service.py | 95 ++++++++----------- 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/services/notification/tests/unit/test_notification_service.py b/services/notification/tests/unit/test_notification_service.py index d7799a350..5554f8c24 100644 --- a/services/notification/tests/unit/test_notification_service.py +++ b/services/notification/tests/unit/test_notification_service.py @@ -1,12 +1,11 @@ import os from asyncio import CancelledError from asyncio import TimeoutError as AsyncioTimeoutError -from unittest.mock import patch import mock import pytest from celery.exceptions import SoftTimeLimitExceeded -from shared.plan.constants import PlanName, TierName +from shared.plan.constants import PlanName from shared.reports.resources import Report, ReportFile, ReportLine from shared.reports.types import Change, ReportTotals from shared.torngit.status import Status @@ -18,7 +17,6 @@ GithubAppInstallation, ) from database.tests.factories import CommitFactory, PullFactory, RepositoryFactory -from database.tests.factories.core import PlanFactory, TierFactory from services.comparison import ComparisonProxy from services.comparison.types import Comparison, EnrichedPull, FullCommit from services.notification import NotificationService @@ -36,6 +34,7 @@ CUSTOM_TARGET_TEXT_PATCH_KEY, CUSTOM_TARGET_TEXT_VALUE, ) +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -79,6 +78,11 @@ def sample_comparison(dbsession, request): class TestNotificationService(object): + @pytest.fixture(autouse=True) + def mock_all_plans_and_tiers_fixture(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_should_use_checks_notifier_yaml_field_false(self, dbsession): repository = RepositoryFactory.create() current_yaml = {"github_checks": False} @@ -125,13 +129,10 @@ def test_should_use_checks_notifier_yaml_field_false(self, dbsession): ), ], ) - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_should_use_checks_notifier_deprecated_flow( - self, plan_objects_get, repo_data, outcome, dbsession + self, repo_data, outcome, dbsession ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan - repository = RepositoryFactory.create(**repo_data) current_yaml = {"github_checks": True} assert repository.owner.github_app_installations == [] @@ -141,12 +142,8 @@ def test_should_use_checks_notifier_deprecated_flow( == outcome ) - @patch("services.notification.Plan.objects.get") - def test_should_use_checks_notifier_ghapp_all_repos_covered( - self, plan_objects_get, dbsession - ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan + @pytest.mark.django_db + def test_should_use_checks_notifier_ghapp_all_repos_covered(self, dbsession): repository = RepositoryFactory.create(owner__service="github") ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -164,19 +161,13 @@ def test_should_use_checks_notifier_ghapp_all_repos_covered( == True ) - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_use_checks_notifier_for_team_plan( self, - plan_objects_get, dbsession, ): - tier = TierFactory.create( - tier_name=TierName.TEAM.value, - ) - plan = PlanFactory.create(tier=tier, name=PlanName.TEAM_MONTHLY.value) - plan_objects_get.return_value = plan repository = RepositoryFactory.create( - owner__service="github", owner__plan=plan.name + owner__service="github", owner__plan=PlanName.TEAM_MONTHLY.value ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -202,16 +193,10 @@ def test_use_checks_notifier_for_team_plan( == True ) - @patch("services.notification.Plan.objects.get") - def test_use_status_notifier_for_team_plan(self, plan_objects_get, dbsession): - tier = TierFactory.create( - tier_name=TierName.TEAM.value, - ) - plan = PlanFactory.create(tier=tier, name=PlanName.TEAM_MONTHLY.value) - plan_objects_get.return_value = plan - + @pytest.mark.django_db + def test_use_status_notifier_for_team_plan(self, dbsession): repository = RepositoryFactory.create( - owner__service="github", owner__plan=plan.name + owner__service="github", owner__plan=PlanName.TEAM_MONTHLY.value ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -237,15 +222,10 @@ def test_use_status_notifier_for_team_plan(self, plan_objects_get, dbsession): == True ) - @patch("services.notification.Plan.objects.get") - def test_use_status_notifier_for_non_team_plan(self, plan_objects_get, dbsession): - tier = TierFactory.create( - tier_name=TierName.PRO.value, - ) - plan = PlanFactory.create(tier=tier, name=PlanName.CODECOV_PRO_MONTHLY.value) - plan_objects_get.return_value = plan + @pytest.mark.django_db + def test_use_status_notifier_for_non_team_plan(self, dbsession): repository = RepositoryFactory.create( - owner__service="github", owner__plan=plan.name + owner__service="github", owner__plan=PlanName.CODECOV_PRO_MONTHLY.value ) ghapp_installation = GithubAppInstallation( name=GITHUB_APP_INSTALLATION_DEFAULT_NAME, @@ -275,12 +255,10 @@ def test_use_status_notifier_for_non_team_plan(self, plan_objects_get, dbsession "gh_installation_name", [GITHUB_APP_INSTALLATION_DEFAULT_NAME, "notifications-app"], ) - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_should_use_checks_notifier_ghapp_some_repos_covered( - self, plan_objects_get, dbsession, gh_installation_name + self, dbsession, gh_installation_name ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan repository = RepositoryFactory.create(owner__service="github") other_repo_same_owner = RepositoryFactory.create(owner=repository.owner) ghapp_installation = GithubAppInstallation( @@ -311,6 +289,7 @@ def test_should_use_checks_notifier_ghapp_some_repos_covered( == False ) + @pytest.mark.django_db def test_get_notifiers_instances_only_third_party( self, dbsession, mock_configuration ): @@ -338,12 +317,10 @@ def test_get_notifiers_instances_only_third_party( assert instance.site_settings == ["slack.com"] assert instance.current_yaml == current_yaml - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_get_notifiers_instances_checks( - self, plan_objects_get, dbsession, mock_configuration, mocker + self, dbsession, mock_configuration, mocker ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan repository = RepositoryFactory.create( owner__integration_id=123, owner__service="github", @@ -377,12 +354,10 @@ def test_get_notifiers_instances_checks( "codecov_slack_app", ] - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_get_notifiers_instances_slack_app_false( - self, plan_objects_get, dbsession, mock_configuration, mocker + self, dbsession, mock_configuration, mocker ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan mocker.patch("services.notification.get_config", return_value=False) repository = RepositoryFactory.create( owner__integration_id=123, @@ -413,17 +388,14 @@ def test_get_notifiers_instances_slack_app_false( "gh_installation_name", [GITHUB_APP_INSTALLATION_DEFAULT_NAME, "notifications-app"], ) - @patch("services.notification.Plan.objects.get") + @pytest.mark.django_db def test_get_notifiers_instances_checks_percentage_whitelist( self, - plan_objects_get, dbsession, mock_configuration, mocker, gh_installation_name, ): - plan = PlanFactory.create() - plan_objects_get.return_value = plan repository = RepositoryFactory.create( owner__integration_id=123, owner__service="github", @@ -472,6 +444,7 @@ def test_get_notifiers_instances_checks_percentage_whitelist( "gh_installation_name", [GITHUB_APP_INSTALLATION_DEFAULT_NAME, "notifications-app"], ) + @pytest.mark.django_db def test_get_notifiers_instances_comment( self, dbsession, mock_configuration, mocker, gh_installation_name ): @@ -495,6 +468,7 @@ def test_get_notifiers_instances_comment( assert len(instances) == 1 assert instances[0].repository_service == gh_installation_name + @pytest.mark.django_db def test_notify_general_exception(self, mocker, dbsession, sample_comparison): current_yaml = {} commit = sample_comparison.head.commit @@ -553,6 +527,7 @@ def test_notify_general_exception(self, mocker, dbsession, sample_comparison): res = notifications_service.notify(sample_comparison) assert expected_result == res + @pytest.mark.django_db def test_notify_data_sent_None(self, mocker, dbsession, sample_comparison): current_yaml = {} commit = sample_comparison.head.commit @@ -617,6 +592,7 @@ def test_notify_data_sent_None(self, mocker, dbsession, sample_comparison): res = notifications_service.notify(sample_comparison) assert expected_result == res + @pytest.mark.django_db def test_notify_individual_notifier_timeout(self, mocker, sample_comparison): current_yaml = {} commit = sample_comparison.head.commit @@ -639,6 +615,7 @@ def test_notify_individual_notifier_timeout(self, mocker, sample_comparison): "title": "fake_notifier", } + @pytest.mark.django_db def test_notify_individual_checks_project_notifier( self, mocker, sample_comparison, mock_repo_provider, mock_configuration ): @@ -690,6 +667,7 @@ def test_notify_individual_checks_project_notifier( ), } + @pytest.mark.django_db def test_notify_individual_checks_patch_notifier_included_helper_text( self, mocker, @@ -849,6 +827,7 @@ def test_notify_individual_checks_patch_notifier_included_helper_text( in r["result"].data_sent["message"] ) + @pytest.mark.django_db def test_notify_individual_notifier_timeout_notification_created( self, mocker, dbsession, sample_comparison ): @@ -883,6 +862,7 @@ def test_notify_individual_notifier_timeout_notification_created( assert pull_commit_notification.decoration_type == notifier.decoration_type assert pull_commit_notification.state == NotificationState.error + @pytest.mark.django_db def test_notify_individual_notifier_notification_created_then_updated( self, mocker, dbsession, sample_comparison ): @@ -932,6 +912,7 @@ def test_notify_individual_notifier_notification_created_then_updated( dbsession.commit() assert pull_commit_notification.state == NotificationState.success + @pytest.mark.django_db def test_notify_individual_notifier_cancellation(self, mocker, sample_comparison): current_yaml = {} commit = sample_comparison.head.commit @@ -950,6 +931,7 @@ def test_notify_individual_notifier_cancellation(self, mocker, sample_comparison notifier, sample_comparison ) + @pytest.mark.django_db def test_notify_timeout_exception(self, mocker, dbsession, sample_comparison): current_yaml = {} commit = sample_comparison.head.commit @@ -1026,6 +1008,7 @@ def test_notify_timeout_exception(self, mocker, dbsession, sample_comparison): Notification.status_patch, ) + @pytest.mark.django_db def test_not_licensed_enterprise(self, mocker, dbsession, sample_comparison): mocker.patch("services.notification.is_properly_licensed", return_value=False) mock_notify_individual_notifier = mocker.patch.object( @@ -1041,6 +1024,7 @@ def test_not_licensed_enterprise(self, mocker, dbsession, sample_comparison): assert expected_result == res assert not mock_notify_individual_notifier.called + @pytest.mark.django_db def test_get_statuses(self, mocker, dbsession, sample_comparison): current_yaml = { "coverage": {"status": {"project": True, "patch": True, "changes": True}}, @@ -1073,6 +1057,7 @@ def test_get_statuses(self, mocker, dbsession, sample_comparison): res = list(notifications_service.get_statuses(["unit", "banana", "strawberry"])) assert expected_result == res + @pytest.mark.django_db def test_get_component_statuses(self, mocker, dbsession, sample_comparison): current_yaml = { "component_management": { From 481d3a9dde862281d2a8bc9686ca10b28707eedd Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Mon, 27 Jan 2025 19:29:37 +0100 Subject: [PATCH 08/13] update with more tests --- .../notify/messages/tests/test_comment.py | 1 + .../tests/integration/test_comment.py | 12 +++ .../notifiers/tests/unit/test_checks.py | 9 ++ .../notifiers/tests/unit/test_comment.py | 85 +++++++++++++++++++ 4 files changed, 107 insertions(+) diff --git a/services/bundle_analysis/notify/messages/tests/test_comment.py b/services/bundle_analysis/notify/messages/tests/test_comment.py index a2c7dbcdd..1ad4e41be 100644 --- a/services/bundle_analysis/notify/messages/tests/test_comment.py +++ b/services/bundle_analysis/notify/messages/tests/test_comment.py @@ -30,6 +30,7 @@ class TestCommentMesage: + @pytest.mark.django_db def test_build_message_from_samples(self, dbsession, mocker, mock_storage): mock_all_plans_and_tiers() head_commit, base_commit = get_commit_pair(dbsession) diff --git a/services/notification/notifiers/tests/integration/test_comment.py b/services/notification/notifiers/tests/integration/test_comment.py index 01126ae03..f6c7b90fe 100644 --- a/services/notification/notifiers/tests/integration/test_comment.py +++ b/services/notification/notifiers/tests/integration/test_comment.py @@ -8,6 +8,7 @@ from services.comparison.types import Comparison, EnrichedPull, FullCommit from services.decoration import Decoration from services.notification.notifiers.comment import CommentNotifier +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -335,6 +336,11 @@ def sample_comparison_for_limited_upload( @pytest.mark.usefixtures("is_not_first_pull") class TestCommentNotifierIntegration(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_notify(self, sample_comparison, codecov_vcr, mock_configuration): sample_comparison.context = ComparisonContext( all_tests_passed=True, test_results_error=None @@ -407,6 +413,7 @@ def test_notify(self, sample_comparison, codecov_vcr, mock_configuration): assert result.data_sent == {"commentid": None, "message": message, "pullid": 9} assert result.data_received == {"id": 1699669247} + @pytest.mark.django_db def test_notify_test_results_error( self, sample_comparison, codecov_vcr, mock_configuration ): @@ -482,6 +489,7 @@ def test_notify_test_results_error( assert result.data_sent == {"commentid": None, "message": message, "pullid": 9} assert result.data_received == {"id": 1699669247} + @pytest.mark.django_db def test_notify_upgrade( self, dbsession, sample_comparison_for_upgrade, codecov_vcr, mock_configuration ): @@ -516,6 +524,7 @@ def test_notify_upgrade( } assert result.data_received == {"id": 1361234119} + @pytest.mark.django_db def test_notify_upload_limited( self, dbsession, @@ -559,6 +568,7 @@ def test_notify_upload_limited( } assert result.data_received == {"id": 1111984446} + @pytest.mark.django_db def test_notify_gitlab( self, sample_comparison_gitlab, codecov_vcr, mock_configuration ): @@ -625,6 +635,7 @@ def test_notify_gitlab( assert result.data_sent == {"commentid": None, "message": message, "pullid": 5} assert result.data_received == {"id": 1457135397} + @pytest.mark.django_db def test_notify_new_layout( self, sample_comparison, codecov_vcr, mock_configuration ): @@ -695,6 +706,7 @@ def test_notify_new_layout( assert result.data_sent == {"commentid": None, "message": message, "pullid": 9} assert result.data_received == {"id": 1699669290} + @pytest.mark.django_db def test_notify_with_components( self, sample_comparison, codecov_vcr, mock_configuration ): diff --git a/services/notification/notifiers/tests/unit/test_checks.py b/services/notification/notifiers/tests/unit/test_checks.py index 4e051307a..c8be6e22f 100644 --- a/services/notification/notifiers/tests/unit/test_checks.py +++ b/services/notification/notifiers/tests/unit/test_checks.py @@ -25,6 +25,7 @@ CUSTOM_TARGET_TEXT_VALUE, ) from services.notification.notifiers.status import PatchStatusNotifier +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -742,9 +743,11 @@ def test_build_upgrade_payload( result = notifier.build_payload(sample_comparison) assert expected_result == result + @pytest.mark.django_db def test_build_default_payload( self, sample_comparison, mock_repo_provider, mock_configuration ): + mock_all_plans_and_tiers() mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br" notifier = PatchChecksNotifier( repository=sample_comparison.head.commit.repository, @@ -1548,9 +1551,11 @@ def test_build_passing_empty_upload_payload( result = notifier.build_payload(sample_comparison) assert expected_result == result + @pytest.mark.django_db def test_build_default_payload( self, sample_comparison, mock_repo_provider, mock_configuration ): + mock_all_plans_and_tiers() mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br" notifier = ProjectChecksNotifier( repository=sample_comparison.head.commit.repository, @@ -1595,9 +1600,11 @@ def test_build_default_payload( ].split("\n") assert expected_result == result + @pytest.mark.django_db def test_build_default_payload_with_flags( self, sample_comparison, mock_repo_provider, mock_configuration ): + mock_all_plans_and_tiers() mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br" notifier = ProjectChecksNotifier( repository=sample_comparison.head.commit.repository, @@ -1642,9 +1649,11 @@ def test_build_default_payload_with_flags( ].split("\n") assert expected_result == result + @pytest.mark.django_db def test_build_default_payload_with_flags_and_footer( self, sample_comparison, mock_repo_provider, mock_configuration ): + mock_all_plans_and_tiers() test_name = "test_build_default_payload_with_flags_and_footer" mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br" notifier = ProjectChecksNotifier( diff --git a/services/notification/notifiers/tests/unit/test_comment.py b/services/notification/notifiers/tests/unit/test_comment.py index 22a5f40af..1d5829694 100644 --- a/services/notification/notifiers/tests/unit/test_comment.py +++ b/services/notification/notifiers/tests/unit/test_comment.py @@ -47,6 +47,7 @@ from services.notification.notifiers.tests.conftest import generate_sample_comparison from services.repository import EnrichedPull from services.yaml.reader import get_components_from_yaml +from tests.helpers import mock_all_plans_and_tiers @pytest.fixture @@ -228,6 +229,7 @@ def mock_repo_provider(mock_repo_provider): class TestCommentNotifierHelpers(object): + @pytest.mark.django_db def test_sort_by_importance(self): modified_change = Change( path="modified.py", @@ -308,6 +310,7 @@ def test_sort_by_importance(self): ] assert expected_result == res + @pytest.mark.django_db def test_format_number_to_str(self): assert "<0.1" == format_number_to_str( {"coverage": {"precision": 1}}, Decimal("0.001") @@ -319,6 +322,7 @@ def test_format_number_to_str(self): {"coverage": {"precision": 1, "round": "up"}}, Decimal("10.001") ) + @pytest.mark.django_db def test_diff_to_string_case_1(self): case_1 = ( "master", @@ -339,6 +343,7 @@ def test_diff_to_string_case_1(self): diff = diff_to_string({}, base_title, base_totals, head_title, head_totals) assert diff == expected_result + @pytest.mark.django_db def test_diff_to_string_case_2(self): case_2 = ( "master", @@ -361,6 +366,7 @@ def test_diff_to_string_case_2(self): diff = diff_to_string({}, base_title, base_totals, head_title, head_totals) assert diff == expected_result + @pytest.mark.django_db def test_diff_to_string_case_3(self): case_3 = ( "master", @@ -386,6 +392,7 @@ def test_diff_to_string_case_3(self): diff = diff_to_string({}, base_title, base_totals, head_title, head_totals) assert diff == expected_result + @pytest.mark.django_db def test_diff_to_string_case_4(self): case_4 = ( "master", @@ -408,6 +415,7 @@ def test_diff_to_string_case_4(self): diff = diff_to_string({}, base_title, base_totals, head_title, head_totals) assert diff == expected_result + @pytest.mark.django_db def test_diff_to_string_case_different_types(self): case_1 = ( "master", @@ -432,6 +440,11 @@ def test_diff_to_string_case_different_types(self): @pytest.mark.usefixtures("is_not_first_pull") class TestCommentNotifier(object): + @pytest.fixture(autouse=True) + def setup(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_is_enabled_settings_individual_settings_false(self, dbsession): repository = RepositoryFactory.create() dbsession.add(repository) @@ -446,6 +459,7 @@ def test_is_enabled_settings_individual_settings_false(self, dbsession): ) assert not notifier.is_enabled() + @pytest.mark.django_db def test_is_enabled_settings_individual_settings_none(self, dbsession): repository = RepositoryFactory.create() dbsession.add(repository) @@ -460,6 +474,7 @@ def test_is_enabled_settings_individual_settings_none(self, dbsession): ) assert not notifier.is_enabled() + @pytest.mark.django_db def test_is_enabled_settings_individual_settings_true(self, dbsession): repository = RepositoryFactory.create() dbsession.add(repository) @@ -474,6 +489,7 @@ def test_is_enabled_settings_individual_settings_true(self, dbsession): ) assert not notifier.is_enabled() + @pytest.mark.django_db def test_is_enabled_settings_individual_settings_dict(self, dbsession): repository = RepositoryFactory.create() dbsession.add(repository) @@ -488,6 +504,7 @@ def test_is_enabled_settings_individual_settings_dict(self, dbsession): ) assert notifier.is_enabled() + @pytest.mark.django_db def test_create_message_files_section( self, dbsession, @@ -639,6 +656,7 @@ def test_create_message_files_section( for expected, res in zip(expected_result, res): assert expected == res + @pytest.mark.django_db def test_create_message_files_section_with_critical_files( self, dbsession, @@ -803,6 +821,7 @@ def test_create_message_files_section_with_critical_files( mocked_search_files_for_critical_changes.call_count == 3 ) # called 2 times by FilesSectionWriter and 1 time by NewFilesSectionWriter + @pytest.mark.django_db def test_create_message_with_github_app_comment( self, dbsession, @@ -834,6 +853,7 @@ def test_create_message_with_github_app_comment( "check_value", return_value=True, ) + @pytest.mark.django_db def test_build_message( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -909,6 +929,7 @@ def test_build_message( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_flags_empty_coverage( self, dbsession, @@ -954,6 +975,7 @@ def test_build_message_flags_empty_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_more_sections( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -1038,6 +1060,7 @@ def test_build_message_more_sections( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_upgrade_message( self, request, @@ -1075,6 +1098,7 @@ def test_build_upgrade_message( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_limited_upload_message( self, request, @@ -1115,6 +1139,7 @@ def test_build_limited_upload_message( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_passing_empty_upload( self, request, @@ -1148,6 +1173,7 @@ def test_build_passing_empty_upload( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_failing_empty_upload( self, request, @@ -1182,6 +1208,7 @@ def test_build_failing_empty_upload( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_processing_upload( self, request, @@ -1214,6 +1241,7 @@ def test_processing_upload( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_upgrade_message_enterprise( self, request, @@ -1257,6 +1285,7 @@ def test_build_upgrade_message_enterprise( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_hide_complexity( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -1331,6 +1360,7 @@ def test_build_message_hide_complexity( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_base_report( self, dbsession, @@ -1406,6 +1436,7 @@ def test_build_message_no_base_report( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_base_commit( self, dbsession, @@ -1481,6 +1512,7 @@ def test_build_message_no_base_commit( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_change( self, dbsession, @@ -1560,6 +1592,7 @@ def test_build_message_no_change( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_negative_change( self, dbsession, @@ -1634,6 +1667,7 @@ def test_build_message_negative_change( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_negative_change_tricky_rounding( self, dbsession, @@ -1701,6 +1735,7 @@ def test_build_message_negative_change_tricky_rounding( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_negative_change_tricky_rounding_newheader( self, dbsession, @@ -1755,6 +1790,7 @@ def test_build_message_negative_change_tricky_rounding_newheader( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_show_carriedforward_flags_no_cf_coverage( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -1830,6 +1866,7 @@ def test_build_message_show_carriedforward_flags_no_cf_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_with_without_flags( self, dbsession, @@ -1960,6 +1997,7 @@ def test_build_message_with_without_flags( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_show_carriedforward_flags_has_cf_coverage( self, dbsession, @@ -2033,6 +2071,7 @@ def test_build_message_show_carriedforward_flags_has_cf_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_hide_carriedforward_flags_has_cf_coverage( self, dbsession, @@ -2104,6 +2143,7 @@ def test_build_message_hide_carriedforward_flags_has_cf_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_send_actual_notification_spammy( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2130,6 +2170,7 @@ def test_send_actual_notification_spammy( assert not mock_repo_provider.edit_comment.called assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_build_message_no_flags( self, dbsession, @@ -2211,6 +2252,7 @@ def test_build_message_no_flags( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_send_actual_notification_new_no_permissions( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2240,6 +2282,7 @@ def test_send_actual_notification_new_no_permissions( assert not mock_repo_provider.post_comment.called assert not mock_repo_provider.edit_comment.called + @pytest.mark.django_db def test_send_actual_notification_new( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2267,6 +2310,7 @@ def test_send_actual_notification_new( assert not mock_repo_provider.edit_comment.called mock_repo_provider.delete_comment.assert_called_with(98, "12345") + @pytest.mark.django_db def test_send_actual_notification_new_no_permissions_post( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2298,6 +2342,7 @@ def test_send_actual_notification_new_no_permissions_post( assert not mock_repo_provider.delete_comment.called assert not mock_repo_provider.edit_comment.called + @pytest.mark.django_db def test_send_actual_notification_new_deleted_comment( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2327,6 +2372,7 @@ def test_send_actual_notification_new_deleted_comment( assert not mock_repo_provider.edit_comment.called mock_repo_provider.delete_comment.assert_called_with(98, "12345") + @pytest.mark.django_db def test_send_actual_notification_once_deleted_comment( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2356,6 +2402,7 @@ def test_send_actual_notification_once_deleted_comment( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_once_non_existing_comment( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2385,6 +2432,7 @@ def test_send_actual_notification_once_non_existing_comment( assert not mock_repo_provider.delete_comment.called assert not mock_repo_provider.edit_comment.called + @pytest.mark.django_db def test_send_actual_notification_once( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2412,6 +2460,7 @@ def test_send_actual_notification_once( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_once_no_permissions( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2441,6 +2490,7 @@ def test_send_actual_notification_once_no_permissions( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_default( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2468,6 +2518,7 @@ def test_send_actual_notification_default( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_default_no_permissions_edit( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2497,6 +2548,7 @@ def test_send_actual_notification_default_no_permissions_edit( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_default_no_permissions_twice( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2528,6 +2580,7 @@ def test_send_actual_notification_default_no_permissions_twice( mock_repo_provider.edit_comment.assert_called_with(98, "12345", "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_send_actual_notification_default_comment_not_found( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2557,6 +2610,7 @@ def test_send_actual_notification_default_comment_not_found( mock_repo_provider.post_comment.assert_called_with(98, "message") assert not mock_repo_provider.delete_comment.called + @pytest.mark.django_db def test_notify_no_pull_request(self, dbsession, sample_comparison_without_pull): notifier = CommentNotifier( repository=sample_comparison_without_pull.head.commit.repository, @@ -2576,6 +2630,7 @@ def test_notify_no_pull_request(self, dbsession, sample_comparison_without_pull) assert result.data_sent is None assert result.data_received is None + @pytest.mark.django_db def test_notify_pull_head_doesnt_match(self, dbsession, sample_comparison): sample_comparison.pull.head = "aaaaaaaaaa" dbsession.flush() @@ -2597,6 +2652,7 @@ def test_notify_pull_head_doesnt_match(self, dbsession, sample_comparison): assert result.data_sent is None assert result.data_received is None + @pytest.mark.django_db def test_notify_pull_request_not_in_provider( self, dbsession, sample_comparison_database_pull_without_provider ): @@ -2618,6 +2674,7 @@ def test_notify_pull_request_not_in_provider( assert result.data_sent is None assert result.data_received is None + @pytest.mark.django_db def test_notify_server_unreachable(self, mocker, dbsession, sample_comparison): mocked_send_actual_notification = mocker.patch.object( CommentNotifier, @@ -2649,6 +2706,7 @@ def test_notify_server_unreachable(self, mocker, dbsession, sample_comparison): } assert result.data_received is None + @pytest.mark.django_db def test_store_results(self, dbsession, sample_comparison): notifier = CommentNotifier( repository=sample_comparison.head.commit.repository, @@ -2675,6 +2733,7 @@ def test_store_results(self, dbsession, sample_comparison): dbsession.refresh(sample_comparison.pull) assert sample_comparison.pull.commentid == "578263422" + @pytest.mark.django_db def test_store_results_deleted_comment(self, dbsession, sample_comparison): sample_comparison.pull.commentid = 12 dbsession.flush() @@ -2703,6 +2762,7 @@ def test_store_results_deleted_comment(self, dbsession, sample_comparison): dbsession.refresh(sample_comparison.pull) assert sample_comparison.pull.commentid is None + @pytest.mark.django_db def test_store_results_no_succesfull_result(self, dbsession, sample_comparison): notifier = CommentNotifier( repository=sample_comparison.head.commit.repository, @@ -2729,6 +2789,7 @@ def test_store_results_no_succesfull_result(self, dbsession, sample_comparison): dbsession.refresh(sample_comparison.pull) assert sample_comparison.pull.commentid is None + @pytest.mark.django_db def test_notify_unable_to_fetch_info(self, dbsession, mocker, sample_comparison): mocked_build_message = mocker.patch.object( CommentNotifier, @@ -2753,6 +2814,7 @@ def test_notify_unable_to_fetch_info(self, dbsession, mocker, sample_comparison) assert result.data_sent is None assert result.data_received is None + @pytest.mark.django_db def test_notify_not_enough_builds(self, dbsession, sample_comparison): notifier = CommentNotifier( repository=sample_comparison.head.commit.repository, @@ -2773,6 +2835,7 @@ def test_notify_not_enough_builds(self, dbsession, sample_comparison): assert result.data_sent is None assert result.data_received is None + @pytest.mark.django_db @pytest.mark.asyncio @pytest.mark.parametrize("pull_state", ["open", "closed"]) async def test_notify_with_enough_builds( @@ -2819,6 +2882,7 @@ async def test_notify_with_enough_builds( } assert result.data_received is None + @pytest.mark.django_db def test_notify_exact_same_report_diff_unrelated_report( self, sample_comparison_no_change, mock_repo_provider ): @@ -2880,6 +2944,7 @@ def test_notify_exact_same_report_diff_unrelated_report( assert res.data_sent is None assert res.data_received is None + @pytest.mark.django_db def test_notify_exact_same_report_diff_unrelated_report_update_comment( self, sample_comparison_no_change, mock_repo_provider ): @@ -2941,6 +3006,7 @@ def test_notify_exact_same_report_diff_unrelated_report_update_comment( assert res.notification_successful is True mock_repo_provider.edit_comment.assert_called() + @pytest.mark.django_db def test_message_hide_details_github( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -2975,6 +3041,7 @@ def test_message_hide_details_github( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_message_announcements_only( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -3012,6 +3079,7 @@ def test_message_announcements_only( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_message_hide_details_bitbucket( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): @@ -3961,6 +4029,11 @@ def test_footer_section_writer_with_project_cov_hidden(self, mocker): @pytest.mark.usefixtures("is_not_first_pull") class TestCommentNotifierInNewLayout(object): + @pytest.fixture(autouse=True) + def mock_all_plans_and_tiers(self): + mock_all_plans_and_tiers() + + @pytest.mark.django_db def test_create_message_files_section_with_critical_files_new_layout( self, dbsession, @@ -4125,6 +4198,7 @@ def test_create_message_files_section_with_critical_files_new_layout( mocked_search_files_for_critical_changes.call_count == 3 ) # called 2 times by FilesSectionWriter and 1 time by NewFilesSectionWriter + @pytest.mark.django_db def test_build_message_no_base_commit_new_layout( self, dbsession, @@ -4194,6 +4268,7 @@ def test_build_message_no_base_commit_new_layout( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_base_report_new_layout( self, dbsession, @@ -4267,6 +4342,7 @@ def test_build_message_no_base_report_new_layout( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_project_coverage( self, dbsession, @@ -4308,6 +4384,7 @@ def test_build_message_no_project_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_no_project_coverage_files( self, dbsession, @@ -4355,6 +4432,7 @@ def test_build_message_no_project_coverage_files( for exp, res in zip(expected_result, result): assert exp == res + @pytest.mark.django_db def test_build_message_no_project_coverage_condensed_yaml_configs( self, dbsession, @@ -4396,6 +4474,7 @@ def test_build_message_no_project_coverage_condensed_yaml_configs( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_head_and_pull_head_differ_new_layout( self, dbsession, @@ -4466,6 +4545,7 @@ def test_build_message_head_and_pull_head_differ_new_layout( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_head_and_pull_head_differ_with_components( self, dbsession, @@ -4548,6 +4628,7 @@ def test_build_message_head_and_pull_head_differ_with_components( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_team_plan_customer_missing_lines( self, dbsession, @@ -4598,6 +4679,7 @@ def test_build_message_team_plan_customer_missing_lines( @patch.object( SHOW_IMPACT_ANALYSIS_DEPRECATION_MSG, "check_value", return_value=True ) + @pytest.mark.django_db def test_build_message_team_plan_customer_all_lines_covered( self, dbsession, @@ -4640,6 +4722,7 @@ def test_build_message_team_plan_customer_all_lines_covered( ] assert result == expected_result + @pytest.mark.django_db def test_build_message_team_plan_customer_all_lines_covered_test_results_error( self, dbsession, @@ -4682,6 +4765,7 @@ def test_build_message_team_plan_customer_all_lines_covered_test_results_error( ] assert result == expected_result + @pytest.mark.django_db def test_build_message_team_plan_customer_all_lines_covered_no_third_line( self, dbsession, @@ -4722,6 +4806,7 @@ def test_build_message_team_plan_customer_all_lines_covered_no_third_line( ] assert result == expected_result + @pytest.mark.django_db def test_build_message_no_patch_or_proj_change( self, dbsession, From da4ed81a33a8bfd46663082578d23fbed7141382 Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Mon, 27 Jan 2025 19:38:09 +0100 Subject: [PATCH 09/13] update with shared version --- requirements.in | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.in b/requirements.in index 8533a5625..5f47e3f62 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser -https://github.com/codecov/shared/archive/e854f50c7c534bb8ca7227fa45e8f069ff1dfe5c.tar.gz#egg=shared +https://github.com/codecov/shared/archive/7804571e81d9195cab11307e02972cfdb5fe3eea.tar.gz#egg=shared https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring asgiref>=3.7.2 analytics-python==1.3.0b1 diff --git a/requirements.txt b/requirements.txt index 4265f9cd5..2805e642a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -375,7 +375,7 @@ sentry-sdk==2.13.0 # shared setuptools==75.7.0 # via nodeenv -shared @ https://github.com/codecov/shared/archive/e854f50c7c534bb8ca7227fa45e8f069ff1dfe5c.tar.gz#egg=shared +shared @ https://github.com/codecov/shared/archive/7804571e81d9195cab11307e02972cfdb5fe3eea.tar.gz#egg=shared # via -r requirements.in six==1.16.0 # via From 801ad17826f0432f7d68de060b1fbe7b2141f23d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 29 Jan 2025 15:18:35 -0800 Subject: [PATCH 10/13] testing stage --- requirements.in | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.in b/requirements.in index cc9cad5e2..6b908bf40 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser -https://github.com/codecov/shared/archive/ce6e1e9198b046af850606e8fe3633d9a25fea98.tar.gz#egg=shared +https://github.com/codecov/shared/archive/a4bd8f76aa40b41772e59fb1993a7c7e5192f0df.tar.gz#egg=shared https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring asgiref>=3.7.2 analytics-python==1.3.0b1 diff --git a/requirements.txt b/requirements.txt index ef16c85e0..3f4dc510c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -377,7 +377,7 @@ sentry-sdk==2.13.0 # shared setuptools==75.7.0 # via nodeenv -shared @ https://github.com/codecov/shared/archive/ce6e1e9198b046af850606e8fe3633d9a25fea98.tar.gz#egg=shared +shared @ https://github.com/codecov/shared/archive/a4bd8f76aa40b41772e59fb1993a7c7e5192f0df.tar.gz#egg=shared # via -r requirements.in six==1.16.0 # via From 111e94279b1607bcd77c8d4c4028bf7376897112 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 29 Jan 2025 15:36:23 -0800 Subject: [PATCH 11/13] fix tests --- services/bundle_analysis/tests/test_bundle_analysis.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/bundle_analysis/tests/test_bundle_analysis.py b/services/bundle_analysis/tests/test_bundle_analysis.py index 29d45bd84..d98349c1f 100644 --- a/services/bundle_analysis/tests/test_bundle_analysis.py +++ b/services/bundle_analysis/tests/test_bundle_analysis.py @@ -30,6 +30,7 @@ ) from services.repository import EnrichedPull from services.urls import get_bundle_analysis_pull_url +from tests.helpers import mock_all_plans_and_tiers class MockBundleReport: @@ -690,6 +691,7 @@ async def test_bundle_analysis_save_measurements_error(dbsession, mocker, mock_s ), ], ) +@pytest.mark.django_db def test_bundle_analysis_notify_bundle_summary( bundle_changes: list[BundleChange], percent_change: float, @@ -700,6 +702,7 @@ def test_bundle_analysis_notify_bundle_summary( mock_storage, mock_repo_provider, ): + mock_all_plans_and_tiers() hook_mock_repo_provider(mocker, mock_repo_provider) base_commit = CommitFactory() dbsession.add(base_commit) @@ -1483,6 +1486,7 @@ def contributing_modules(self, pr_changed_files): ), ], ) +@pytest.mark.django_db def test_bundle_analysis_notify_individual_bundle_data( bundle_changes: list[BundleChange], route_changes: Dict[str, List[RouteChange]], @@ -1493,6 +1497,7 @@ def test_bundle_analysis_notify_individual_bundle_data( mock_storage, mock_repo_provider, ): + mock_all_plans_and_tiers() percent_change = 5.56 user_config = { **PATCH_CENTRIC_DEFAULT_CONFIG, From 0aa6e04a35fec533ef11202b3ce23bbc7d0dde73 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 29 Jan 2025 16:26:42 -0800 Subject: [PATCH 12/13] fix these other tests --- services/notification/notifiers/tests/unit/test_comment.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/notification/notifiers/tests/unit/test_comment.py b/services/notification/notifiers/tests/unit/test_comment.py index 5c720dd4f..82cba814e 100644 --- a/services/notification/notifiers/tests/unit/test_comment.py +++ b/services/notification/notifiers/tests/unit/test_comment.py @@ -2143,6 +2143,7 @@ def test_build_message_hide_carriedforward_flags_has_cf_coverage( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_build_message_default_layout( self, dbsession, @@ -2174,6 +2175,7 @@ def test_build_message_default_layout( assert exp == res assert result == expected_result + @pytest.mark.django_db def test_send_actual_notification_spammy( self, dbsession, mock_configuration, mock_repo_provider, sample_comparison ): From 759bc6666e37c37b5560bb7f0502f2c26f596b2e Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Thu, 30 Jan 2025 17:47:49 +0100 Subject: [PATCH 13/13] update with new shared version --- requirements.in | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.in b/requirements.in index 6b908bf40..8904a70cc 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ https://github.com/codecov/test-results-parser/archive/190bbc8a911099749928e13d5fe57f6027ca1e74.tar.gz#egg=test-results-parser -https://github.com/codecov/shared/archive/a4bd8f76aa40b41772e59fb1993a7c7e5192f0df.tar.gz#egg=shared +https://github.com/codecov/shared/archive/74c0888070699b69a4da73f54be502ad05fde7b6.tar.gz#egg=shared https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring asgiref>=3.7.2 analytics-python==1.3.0b1 diff --git a/requirements.txt b/requirements.txt index 3f4dc510c..687834108 100644 --- a/requirements.txt +++ b/requirements.txt @@ -377,7 +377,7 @@ sentry-sdk==2.13.0 # shared setuptools==75.7.0 # via nodeenv -shared @ https://github.com/codecov/shared/archive/a4bd8f76aa40b41772e59fb1993a7c7e5192f0df.tar.gz#egg=shared +shared @ https://github.com/codecov/shared/archive/74c0888070699b69a4da73f54be502ad05fde7b6.tar.gz#egg=shared # via -r requirements.in six==1.16.0 # via