diff --git a/codecov/db/__init__.py b/codecov/db/__init__.py index fb3b925d3f..28a91e3aa4 100644 --- a/codecov/db/__init__.py +++ b/codecov/db/__init__.py @@ -1,8 +1,6 @@ import logging -from asgiref.sync import SyncToAsync from django.conf import settings -from django.db import close_old_connections from django.db.models import Field, Lookup log = logging.getLogger(__name__) @@ -69,19 +67,3 @@ def as_sql(self, compiler, connection): rhs, rhs_params = self.process_rhs(compiler, connection) params = tuple(lhs_params) + tuple(rhs_params) return "%s is not %s" % (lhs, rhs), params - - -class DatabaseSyncToAsync(SyncToAsync): - """ - SyncToAsync version that cleans up old database connections. - """ - - def thread_handler(self, loop, *args, **kwargs): - close_old_connections() - try: - return super().thread_handler(loop, *args, **kwargs) - finally: - close_old_connections() - - -sync_to_async = DatabaseSyncToAsync diff --git a/codecov_auth/commands/owner/interactors/cancel_trial.py b/codecov_auth/commands/owner/interactors/cancel_trial.py index 556234b2a0..9834dc418d 100644 --- a/codecov_auth/commands/owner/interactors/cancel_trial.py +++ b/codecov_auth/commands/owner/interactors/cancel_trial.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from shared.plan.service import PlanService from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/create_api_token.py b/codecov_auth/commands/owner/interactors/create_api_token.py index d34d8c79b5..e1692d36e0 100644 --- a/codecov_auth/commands/owner/interactors/create_api_token.py +++ b/codecov_auth/commands/owner/interactors/create_api_token.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import Session diff --git a/codecov_auth/commands/owner/interactors/create_stripe_setup_intent.py b/codecov_auth/commands/owner/interactors/create_stripe_setup_intent.py index 0fc5598a67..f7624c8cfa 100644 --- a/codecov_auth/commands/owner/interactors/create_stripe_setup_intent.py +++ b/codecov_auth/commands/owner/interactors/create_stripe_setup_intent.py @@ -1,10 +1,10 @@ import logging import stripe +from asgiref.sync import sync_to_async from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner from services.billing import BillingService diff --git a/codecov_auth/commands/owner/interactors/create_user_token.py b/codecov_auth/commands/owner/interactors/create_user_token.py index b426fc43fc..8d60818785 100644 --- a/codecov_auth/commands/owner/interactors/create_user_token.py +++ b/codecov_auth/commands/owner/interactors/create_user_token.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import UserToken diff --git a/codecov_auth/commands/owner/interactors/delete_session.py b/codecov_auth/commands/owner/interactors/delete_session.py index 6e90239703..dd1aae6b05 100644 --- a/codecov_auth/commands/owner/interactors/delete_session.py +++ b/codecov_auth/commands/owner/interactors/delete_session.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from django.contrib.sessions.models import Session as DjangoSession from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from codecov_auth.models import Session diff --git a/codecov_auth/commands/owner/interactors/fetch_owner.py b/codecov_auth/commands/owner/interactors/fetch_owner.py index 316159d366..bb32216fd4 100644 --- a/codecov_auth/commands/owner/interactors/fetch_owner.py +++ b/codecov_auth/commands/owner/interactors/fetch_owner.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/get_org_upload_token.py b/codecov_auth/commands/owner/interactors/get_org_upload_token.py index b2a8fe510e..7a07c7d141 100644 --- a/codecov_auth/commands/owner/interactors/get_org_upload_token.py +++ b/codecov_auth/commands/owner/interactors/get_org_upload_token.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import OrganizationLevelToken diff --git a/codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py b/codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py index 02fe9d2465..7702b955ba 100644 --- a/codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py +++ b/codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py @@ -1,10 +1,10 @@ from typing import Optional +from asgiref.sync import sync_to_async from shared.plan.service import PlanService from shared.upload.utils import query_monthly_coverage_measurements from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from codecov_auth.models import Owner from services.redis_configuration import get_redis_connection diff --git a/codecov_auth/commands/owner/interactors/is_syncing.py b/codecov_auth/commands/owner/interactors/is_syncing.py index cabfb98435..94971cb526 100644 --- a/codecov_auth/commands/owner/interactors/is_syncing.py +++ b/codecov_auth/commands/owner/interactors/is_syncing.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from services.refresh import RefreshService diff --git a/codecov_auth/commands/owner/interactors/onboard_user.py b/codecov_auth/commands/owner/interactors/onboard_user.py index fb6928df20..1d72cbacfe 100644 --- a/codecov_auth/commands/owner/interactors/onboard_user.py +++ b/codecov_auth/commands/owner/interactors/onboard_user.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from django import forms from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import OwnerProfile diff --git a/codecov_auth/commands/owner/interactors/regenerate_org_upload_token.py b/codecov_auth/commands/owner/interactors/regenerate_org_upload_token.py index cc9b035db0..5eb94c566d 100644 --- a/codecov_auth/commands/owner/interactors/regenerate_org_upload_token.py +++ b/codecov_auth/commands/owner/interactors/regenerate_org_upload_token.py @@ -1,8 +1,9 @@ import uuid +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import OrganizationLevelToken, Owner diff --git a/codecov_auth/commands/owner/interactors/revoke_user_token.py b/codecov_auth/commands/owner/interactors/revoke_user_token.py index 57aeb6166f..904f338a65 100644 --- a/codecov_auth/commands/owner/interactors/revoke_user_token.py +++ b/codecov_auth/commands/owner/interactors/revoke_user_token.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from codecov_auth.models import UserToken diff --git a/codecov_auth/commands/owner/interactors/save_okta_config.py b/codecov_auth/commands/owner/interactors/save_okta_config.py index e6b51ac7c8..46c9c84904 100644 --- a/codecov_auth/commands/owner/interactors/save_okta_config.py +++ b/codecov_auth/commands/owner/interactors/save_okta_config.py @@ -1,10 +1,10 @@ from dataclasses import dataclass +from asgiref.sync import sync_to_async from shared.django_apps.codecov_auth.models import AccountsUsers, User from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import Account, OktaSettings, Owner diff --git a/codecov_auth/commands/owner/interactors/save_terms_agreement.py b/codecov_auth/commands/owner/interactors/save_terms_agreement.py index 4df6d79db3..acef9c5324 100644 --- a/codecov_auth/commands/owner/interactors/save_terms_agreement.py +++ b/codecov_auth/commands/owner/interactors/save_terms_agreement.py @@ -1,11 +1,11 @@ from dataclasses import dataclass from typing import Any, Optional +from asgiref.sync import sync_to_async from django.utils import timezone from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async from services.analytics import AnalyticsService diff --git a/codecov_auth/commands/owner/interactors/set_upload_token_required.py b/codecov_auth/commands/owner/interactors/set_upload_token_required.py index 9a0113b648..10ba28164b 100644 --- a/codecov_auth/commands/owner/interactors/set_upload_token_required.py +++ b/codecov_auth/commands/owner/interactors/set_upload_token_required.py @@ -1,8 +1,9 @@ from dataclasses import dataclass +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/set_yaml_on_owner.py b/codecov_auth/commands/owner/interactors/set_yaml_on_owner.py index 12a131e21f..e177a564b2 100644 --- a/codecov_auth/commands/owner/interactors/set_yaml_on_owner.py +++ b/codecov_auth/commands/owner/interactors/set_yaml_on_owner.py @@ -2,6 +2,7 @@ from typing import Optional import yaml +from asgiref.sync import sync_to_async from shared.django_apps.core.models import Repository from shared.django_apps.utils.model_utils import get_ownerid_if_member from shared.validation.exceptions import InvalidYamlException @@ -14,7 +15,6 @@ Unauthorized, ValidationError, ) -from codecov.db import sync_to_async from codecov_auth.constants import OWNER_YAML_TO_STRING_KEY from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/start_trial.py b/codecov_auth/commands/owner/interactors/start_trial.py index c14f2c6229..5abd36a8a2 100644 --- a/codecov_auth/commands/owner/interactors/start_trial.py +++ b/codecov_auth/commands/owner/interactors/start_trial.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from shared.plan.service import PlanService from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/store_codecov_metric.py b/codecov_auth/commands/owner/interactors/store_codecov_metric.py index aa2ac0b69e..c52cad8596 100644 --- a/codecov_auth/commands/owner/interactors/store_codecov_metric.py +++ b/codecov_auth/commands/owner/interactors/store_codecov_metric.py @@ -1,12 +1,12 @@ import json +from asgiref.sync import sync_to_async from shared.django_apps.codecov_metrics.service.codecov_metrics import ( UserOnboardingMetricsService, ) from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from codecov_auth.models import Owner diff --git a/codecov_auth/commands/owner/interactors/tests/test_cancel_trial.py b/codecov_auth/commands/owner/interactors/tests/test_cancel_trial.py index d328b55867..fde8a2380d 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_cancel_trial.py +++ b/codecov_auth/commands/owner/interactors/tests/test_cancel_trial.py @@ -2,7 +2,7 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from shared.django_apps.codecov.commands.exceptions import ValidationError from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory @@ -16,7 +16,7 @@ from ..cancel_trial import CancelTrialInteractor -class CancelTrialInteractorTest(TransactionTestCase): +class CancelTrialInteractorTest(TestCase): def setUp(self): self.tier = TierFactory(tier_name=DEFAULT_FREE_PLAN) self.plan = PlanFactory(tier=self.tier) diff --git a/codecov_auth/commands/owner/interactors/tests/test_create_api_token.py b/codecov_auth/commands/owner/interactors/tests/test_create_api_token.py index 82440d9e65..f8c3487b60 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_create_api_token.py +++ b/codecov_auth/commands/owner/interactors/tests/test_create_api_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, ValidationError @@ -7,7 +7,7 @@ from ..create_api_token import CreateApiTokenInteractor -class CreateApiTokenInteractorTest(TransactionTestCase): +class CreateApiTokenInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_create_user_token.py b/codecov_auth/commands/owner/interactors/tests/test_create_user_token.py index 218b831ae7..ea606a7d16 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_create_user_token.py +++ b/codecov_auth/commands/owner/interactors/tests/test_create_user_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, ValidationError @@ -8,7 +8,7 @@ from ..create_user_token import CreateUserTokenInteractor -class CreateUserTokenInteractorTest(TransactionTestCase): +class CreateUserTokenInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_delete_session.py b/codecov_auth/commands/owner/interactors/tests/test_delete_session.py index e4a8c24df5..d5c500045f 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_delete_session.py +++ b/codecov_auth/commands/owner/interactors/tests/test_delete_session.py @@ -1,9 +1,9 @@ import pytest -from django.test import TransactionTestCase +from asgiref.sync import sync_to_async +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import OwnerFactory, SessionFactory from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from codecov_auth.models import DjangoSession, Session from codecov_auth.tests.factories import DjangoSessionFactory @@ -15,7 +15,7 @@ def get_session(id): return Session.objects.get(sessionid=id) -class DeleteSessionInteractorTest(TransactionTestCase): +class DeleteSessionInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.django_session = DjangoSessionFactory() diff --git a/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py b/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py index f495d0adf7..be65f3cb33 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py +++ b/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py @@ -1,7 +1,7 @@ from unittest.mock import patch from asgiref.sync import async_to_sync -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.codecov_auth.tests.factories import ( GetAdminProviderAdapter, OwnerFactory, @@ -13,7 +13,7 @@ ) -class GetIsCurrentUserAnAdminInteractorTest(TransactionTestCase): +class GetIsCurrentUserAnAdminInteractorTest(TestCase): def setUp(self): self.owner_has_admins = OwnerFactory(ownerid=0, admins=[2]) self.owner_has_no_admins = OwnerFactory(ownerid=1, admins=[]) diff --git a/codecov_auth/commands/owner/interactors/tests/test_get_org_upload_token.py b/codecov_auth/commands/owner/interactors/tests/test_get_org_upload_token.py index 7b14a43ce5..193484648c 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_get_org_upload_token.py +++ b/codecov_auth/commands/owner/interactors/tests/test_get_org_upload_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( OrganizationLevelTokenFactory, OwnerFactory, @@ -10,7 +10,7 @@ from ..get_org_upload_token import GetOrgUploadToken -class GetOrgUploadTokenInteractorTest(TransactionTestCase): +class GetOrgUploadTokenInteractorTest(TestCase): def setUp(self): self.owner_with_no_upload_token = OwnerFactory() self.owner_with_upload_token = OwnerFactory(plan="users-enterprisem") diff --git a/codecov_auth/commands/owner/interactors/tests/test_get_uploads_number_per_user.py b/codecov_auth/commands/owner/interactors/tests/test_get_uploads_number_per_user.py index 2b4cf1fd56..4812a831d3 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_get_uploads_number_per_user.py +++ b/codecov_auth/commands/owner/interactors/tests/test_get_uploads_number_per_user.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory from shared.django_apps.core.tests.factories import ( CommitFactory, @@ -16,7 +16,7 @@ from ..get_uploads_number_per_user import GetUploadsNumberPerUserInteractor -class GetUploadsNumberPerUserInteractorTest(TransactionTestCase): +class GetUploadsNumberPerUserInteractorTest(TestCase): def setUp(self): self.tier = TierFactory(tier_name=TierName.BASIC.value) self.plan = PlanFactory(tier=self.tier, monthly_uploads_limit=250) diff --git a/codecov_auth/commands/owner/interactors/tests/test_is_syncing.py b/codecov_auth/commands/owner/interactors/tests/test_is_syncing.py index 79fecf124b..4c37daac67 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_is_syncing.py +++ b/codecov_auth/commands/owner/interactors/tests/test_is_syncing.py @@ -1,13 +1,13 @@ from unittest.mock import patch from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from ..is_syncing import IsSyncingInteractor -class IsSyncingInteractorTest(TransactionTestCase): +class IsSyncingInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_onboard_user.py b/codecov_auth/commands/owner/interactors/tests/test_onboard_user.py index a19bcdccb9..ead455d755 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_onboard_user.py +++ b/codecov_auth/commands/owner/interactors/tests/test_onboard_user.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError @@ -7,7 +7,7 @@ from codecov_auth.models import OwnerProfile -class OnboardUserInteractorTest(TransactionTestCase): +class OnboardUserInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.already_onboarded_owner = OwnerFactory( diff --git a/codecov_auth/commands/owner/interactors/tests/test_regenerate_org_upload_token.py b/codecov_auth/commands/owner/interactors/tests/test_regenerate_org_upload_token.py index 875564fa4a..388b4a9d97 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_regenerate_org_upload_token.py +++ b/codecov_auth/commands/owner/interactors/tests/test_regenerate_org_upload_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError @@ -7,7 +7,7 @@ from ..regenerate_org_upload_token import RegenerateOrgUploadTokenInteractor -class RegenerateOrgUploadTokenInteractorTest(TransactionTestCase): +class RegenerateOrgUploadTokenInteractorTest(TestCase): def setUp(self): self.random_user = OwnerFactory() self.owner = OwnerFactory(username="codecovv", plan="users-enterprisem") diff --git a/codecov_auth/commands/owner/interactors/tests/test_revoke_user_token.py b/codecov_auth/commands/owner/interactors/tests/test_revoke_user_token.py index bd7a298567..8e6e645a08 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_revoke_user_token.py +++ b/codecov_auth/commands/owner/interactors/tests/test_revoke_user_token.py @@ -1,12 +1,12 @@ import pytest -from django.test import TransactionTestCase +from asgiref.sync import sync_to_async +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( OwnerFactory, UserTokenFactory, ) from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from codecov_auth.models import UserToken from ..revoke_user_token import RevokeUserTokenInteractor @@ -17,7 +17,7 @@ def get_user_token(external_id): return UserToken.objects.get(external_id=external_id) -class RevokeUserTokenInteractorTest(TransactionTestCase): +class RevokeUserTokenInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.user_token = UserTokenFactory(owner=self.owner) diff --git a/codecov_auth/commands/owner/interactors/tests/test_save_okta_config.py b/codecov_auth/commands/owner/interactors/tests/test_save_okta_config.py index 18a87ed12b..8d00cce30e 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_save_okta_config.py +++ b/codecov_auth/commands/owner/interactors/tests/test_save_okta_config.py @@ -1,7 +1,7 @@ import pytest from asgiref.sync import async_to_sync from django.contrib.auth.models import AnonymousUser -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( AccountFactory, OktaSettingsFactory, @@ -14,7 +14,7 @@ from ..save_okta_config import SaveOktaConfigInteractor -class SaveOktaConfigInteractorTest(TransactionTestCase): +class SaveOktaConfigInteractorTest(TestCase): def setUp(self): self.current_user = OwnerFactory(username="codecov-user") self.service = "github" diff --git a/codecov_auth/commands/owner/interactors/tests/test_save_terms_agreement.py b/codecov_auth/commands/owner/interactors/tests/test_save_terms_agreement.py index 70c754f232..07803acc4e 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_save_terms_agreement.py +++ b/codecov_auth/commands/owner/interactors/tests/test_save_terms_agreement.py @@ -3,7 +3,7 @@ import pytest from asgiref.sync import async_to_sync from django.contrib.auth.models import AnonymousUser -from django.test import TransactionTestCase +from django.test import TestCase from django.utils import timezone from freezegun import freeze_time from freezegun.api import FakeDatetime @@ -14,7 +14,7 @@ from ..save_terms_agreement import SaveTermsAgreementInteractor -class UpdateSaveTermsAgreementInteractorTest(TransactionTestCase): +class UpdateSaveTermsAgreementInteractorTest(TestCase): def setUp(self): self.current_user = UserFactory(name="codecov-user") self.updated_at = FakeDatetime(2022, 1, 1, 0, 0, 0, tzinfo=timezone.utc) diff --git a/codecov_auth/commands/owner/interactors/tests/test_set_upload_token_required.py b/codecov_auth/commands/owner/interactors/tests/test_set_upload_token_required.py index 1e7878f5f5..205b12af1d 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_set_upload_token_required.py +++ b/codecov_auth/commands/owner/interactors/tests/test_set_upload_token_required.py @@ -1,6 +1,6 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError @@ -8,7 +8,7 @@ from ..set_upload_token_required import SetUploadTokenRequiredInteractor -class SetUploadTokenRequiredInteractorTest(TransactionTestCase): +class SetUploadTokenRequiredInteractorTest(TestCase): def setUp(self): self.service = "github" self.current_user = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_set_yaml_on_owner.py b/codecov_auth/commands/owner/interactors/tests/test_set_yaml_on_owner.py index 5c03f955f4..b82ad35232 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_set_yaml_on_owner.py +++ b/codecov_auth/commands/owner/interactors/tests/test_set_yaml_on_owner.py @@ -1,5 +1,6 @@ import pytest -from django.test import TransactionTestCase +from asgiref.sync import sync_to_async +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from codecov.commands.exceptions import ( @@ -8,7 +9,6 @@ Unauthorized, ValidationError, ) -from codecov.db import sync_to_async from ..set_yaml_on_owner import SetYamlOnOwnerInteractor @@ -59,7 +59,7 @@ """ -class SetYamlOnOwnerInteractorTest(TransactionTestCase): +class SetYamlOnOwnerInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.current_owner = OwnerFactory( diff --git a/codecov_auth/commands/owner/interactors/tests/test_start_trial.py b/codecov_auth/commands/owner/interactors/tests/test_start_trial.py index a95562c42a..fe00a38d90 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_start_trial.py +++ b/codecov_auth/commands/owner/interactors/tests/test_start_trial.py @@ -2,7 +2,7 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from shared.django_apps.codecov.commands.exceptions import ValidationError from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory @@ -22,7 +22,7 @@ from ..start_trial import StartTrialInteractor -class StartTrialInteractorTest(TransactionTestCase): +class StartTrialInteractorTest(TestCase): def setUp(self): self.tier = TierFactory(tier_name=TierName.BASIC.value) self.plan = PlanFactory(tier=self.tier, is_active=True) diff --git a/codecov_auth/commands/owner/interactors/tests/test_trigger_sync.py b/codecov_auth/commands/owner/interactors/tests/test_trigger_sync.py index e59d6b163c..8004aa6016 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_trigger_sync.py +++ b/codecov_auth/commands/owner/interactors/tests/test_trigger_sync.py @@ -1,7 +1,7 @@ from unittest.mock import patch import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated @@ -9,7 +9,7 @@ from ..trigger_sync import TriggerSyncInteractor -class IsSyncingInteractorTest(TransactionTestCase): +class IsSyncingInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_update_default_organization.py b/codecov_auth/commands/owner/interactors/tests/test_update_default_organization.py index db91388efe..e0c310e382 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_update_default_organization.py +++ b/codecov_auth/commands/owner/interactors/tests/test_update_default_organization.py @@ -2,7 +2,7 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, ValidationError @@ -11,7 +11,7 @@ from ..update_default_organization import UpdateDefaultOrganizationInteractor -class UpdateDefaultOrganizationInteractorTest(TransactionTestCase): +class UpdateDefaultOrganizationInteractorTest(TestCase): def setUp(self): self.default_organization_username = "sample-default-org-username" self.default_organization = OwnerFactory( diff --git a/codecov_auth/commands/owner/interactors/tests/test_update_profile.py b/codecov_auth/commands/owner/interactors/tests/test_update_profile.py index 596f19ea3f..95393f9db4 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_update_profile.py +++ b/codecov_auth/commands/owner/interactors/tests/test_update_profile.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, ValidationError @@ -7,7 +7,7 @@ from ..update_profile import UpdateProfileInteractor -class UpdateProfileInteractorTest(TransactionTestCase): +class UpdateProfileInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/codecov_auth/commands/owner/interactors/tests/test_update_self_hosted_settings.py b/codecov_auth/commands/owner/interactors/tests/test_update_self_hosted_settings.py index e1679104a0..cb16ec6691 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_update_self_hosted_settings.py +++ b/codecov_auth/commands/owner/interactors/tests/test_update_self_hosted_settings.py @@ -1,7 +1,7 @@ import pytest from asgiref.sync import async_to_sync from django.contrib.auth.models import AnonymousUser -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthenticated, ValidationError @@ -10,7 +10,7 @@ ) -class UpdateSelfHostedSettingsInteractorTest(TransactionTestCase): +class UpdateSelfHostedSettingsInteractorTest(TestCase): @async_to_sync def execute( self, diff --git a/codecov_auth/commands/owner/interactors/trigger_sync.py b/codecov_auth/commands/owner/interactors/trigger_sync.py index 66f2381a85..32f6028431 100644 --- a/codecov_auth/commands/owner/interactors/trigger_sync.py +++ b/codecov_auth/commands/owner/interactors/trigger_sync.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from services.refresh import RefreshService diff --git a/codecov_auth/commands/owner/interactors/update_default_organization.py b/codecov_auth/commands/owner/interactors/update_default_organization.py index 07c475776e..023e7583b2 100644 --- a/codecov_auth/commands/owner/interactors/update_default_organization.py +++ b/codecov_auth/commands/owner/interactors/update_default_organization.py @@ -1,8 +1,9 @@ from typing import Optional +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import Owner, OwnerProfile from services.activation import try_auto_activate diff --git a/codecov_auth/commands/owner/interactors/update_profile.py b/codecov_auth/commands/owner/interactors/update_profile.py index dc1d084efd..6ff5666550 100644 --- a/codecov_auth/commands/owner/interactors/update_profile.py +++ b/codecov_auth/commands/owner/interactors/update_profile.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from django import forms from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async class UpdateProfileForm(forms.Form): diff --git a/codecov_auth/commands/owner/interactors/update_self_hosted_settings.py b/codecov_auth/commands/owner/interactors/update_self_hosted_settings.py index 174acee4c6..5464a323c7 100644 --- a/codecov_auth/commands/owner/interactors/update_self_hosted_settings.py +++ b/codecov_auth/commands/owner/interactors/update_self_hosted_settings.py @@ -1,11 +1,11 @@ from dataclasses import dataclass +from asgiref.sync import sync_to_async from django.conf import settings import services.self_hosted as self_hosted from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async @dataclass diff --git a/codecov_auth/commands/owner/tests/test_owner.py b/codecov_auth/commands/owner/tests/test_owner.py index 028813a3e1..cd8456e3f6 100644 --- a/codecov_auth/commands/owner/tests/test_owner.py +++ b/codecov_auth/commands/owner/tests/test_owner.py @@ -1,12 +1,12 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from ..owner import OwnerCommands -class OwnerCommandsTest(TransactionTestCase): +class OwnerCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.command = OwnerCommands(self.owner, "github") diff --git a/codecov_auth/tests/unit/services/test_org_level_token_service.py b/codecov_auth/tests/unit/services/test_org_level_token_service.py index 79c13503ce..5c13134f8a 100644 --- a/codecov_auth/tests/unit/services/test_org_level_token_service.py +++ b/codecov_auth/tests/unit/services/test_org_level_token_service.py @@ -3,7 +3,7 @@ import pytest from django.forms import ValidationError -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( OrganizationLevelTokenFactory, OwnerFactory, @@ -37,7 +37,7 @@ def test_token_is_deleted_when_changing_user_plan(mocked_org_can_have_upload_tok assert OrganizationLevelToken.objects.filter(owner=owner).count() == 0 -class TestOrgWideUploadTokenService(TransactionTestCase): +class TestOrgWideUploadTokenService(TestCase): def setUp(self): self.enterprise_tier = TierFactory(tier_name=TierName.ENTERPRISE.value) self.enterprise_plan = PlanFactory( diff --git a/codecov_auth/tests/unit/test_authentication.py b/codecov_auth/tests/unit/test_authentication.py index 88f8a1bfbe..47c898d399 100644 --- a/codecov_auth/tests/unit/test_authentication.py +++ b/codecov_auth/tests/unit/test_authentication.py @@ -4,7 +4,7 @@ import pytest from django.conf import settings -from django.test import TestCase, TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.urls import ResolverMatch from rest_framework.exceptions import AuthenticationFailed, PermissionDenied from rest_framework.test import APIRequestFactory @@ -178,7 +178,7 @@ def test_bearer_token_default_token_envar_and_same_string_as_header(self): authenticator.authenticate(request) -class ImpersonationTests(TransactionTestCase): +class ImpersonationTests(TestCase): def setUp(self): self.owner_to_impersonate = OwnerFactory( username="impersonateme", service="github", user=UserFactory(is_staff=False) diff --git a/codecov_auth/tests/unit/views/test_logout.py b/codecov_auth/tests/unit/views/test_logout.py index ac3c603220..53132a35fb 100644 --- a/codecov_auth/tests/unit/views/test_logout.py +++ b/codecov_auth/tests/unit/views/test_logout.py @@ -1,10 +1,10 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from utils.test_utils import Client -class LogoutViewTest(TransactionTestCase): +class LogoutViewTest(TestCase): def _get(self, url): return self.client.get(url, content_type="application/json") diff --git a/compare/commands/compare/interactors/tests/test_fetch_impacted_files.py b/compare/commands/compare/interactors/tests/test_fetch_impacted_files.py index 2d5a8844bb..ec36e936e4 100644 --- a/compare/commands/compare/interactors/tests/test_fetch_impacted_files.py +++ b/compare/commands/compare/interactors/tests/test_fetch_impacted_files.py @@ -1,7 +1,7 @@ import enum from unittest.mock import PropertyMock, patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -343,7 +343,7 @@ class OrderingDirection(enum.Enum): """ -class FetchImpactedFilesTest(TransactionTestCase): +class FetchImpactedFilesTest(TestCase): def setUp(self): self.user = OwnerFactory(username="codecov-user") self.parent_commit = CommitFactory() diff --git a/core/commands/branch/interactors/fetch_branch.py b/core/commands/branch/interactors/fetch_branch.py index 3ad579ff2c..60410484d9 100644 --- a/core/commands/branch/interactors/fetch_branch.py +++ b/core/commands/branch/interactors/fetch_branch.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class FetchBranchInteractor(BaseInteractor): diff --git a/core/commands/branch/interactors/fetch_branches.py b/core/commands/branch/interactors/fetch_branches.py index 2d6976729e..e19e7ae4d7 100644 --- a/core/commands/branch/interactors/fetch_branches.py +++ b/core/commands/branch/interactors/fetch_branches.py @@ -1,10 +1,10 @@ from typing import Any +from asgiref.sync import sync_to_async from django.db.models import OuterRef, Q, QuerySet, Subquery from shared.django_apps.core.models import Repository from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from core.models import Commit diff --git a/core/commands/branch/interactors/tests/test_fetch_branch.py b/core/commands/branch/interactors/tests/test_fetch_branch.py index ba07230f93..7169ab7a3a 100644 --- a/core/commands/branch/interactors/tests/test_fetch_branch.py +++ b/core/commands/branch/interactors/tests/test_fetch_branch.py @@ -1,10 +1,10 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import BranchFactory, OwnerFactory from ..fetch_branch import FetchBranchInteractor -class FetchBranchInteractorTest(TransactionTestCase): +class FetchBranchInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.branch = BranchFactory() diff --git a/core/commands/branch/interactors/tests/test_fetch_branches.py b/core/commands/branch/interactors/tests/test_fetch_branches.py index c66fbb0c91..5b5a3589b7 100644 --- a/core/commands/branch/interactors/tests/test_fetch_branches.py +++ b/core/commands/branch/interactors/tests/test_fetch_branches.py @@ -1,7 +1,7 @@ from typing import Any from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( BranchFactory, CommitFactory, @@ -12,7 +12,7 @@ from ..fetch_branches import FetchRepoBranchesInteractor -class FetchRepoBranchesInteractorTest(TransactionTestCase): +class FetchRepoBranchesInteractorTest(TestCase): def setUp(self) -> None: self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory( diff --git a/core/commands/branch/tests/test_branch.py b/core/commands/branch/tests/test_branch.py index b44fa79e80..c661127fcf 100644 --- a/core/commands/branch/tests/test_branch.py +++ b/core/commands/branch/tests/test_branch.py @@ -1,12 +1,12 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from ..branch import BranchCommands -class BranchCommandsTest(TransactionTestCase): +class BranchCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.repository = RepositoryFactory() diff --git a/core/commands/commit/interactors/fetch_totals.py b/core/commands/commit/interactors/fetch_totals.py index 0abf1d66c7..6d46b61bf2 100644 --- a/core/commands/commit/interactors/fetch_totals.py +++ b/core/commands/commit/interactors/fetch_totals.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class FetchTotalsInteractor(BaseInteractor): diff --git a/core/commands/commit/interactors/get_commit_errors.py b/core/commands/commit/interactors/get_commit_errors.py index 669b06650c..83414615ba 100644 --- a/core/commands/commit/interactors/get_commit_errors.py +++ b/core/commands/commit/interactors/get_commit_errors.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from graphql_api.types.enums import CommitErrorCode, CommitErrorGeneralType diff --git a/core/commands/commit/interactors/get_final_yaml.py b/core/commands/commit/interactors/get_final_yaml.py index c020042661..059f55f125 100644 --- a/core/commands/commit/interactors/get_final_yaml.py +++ b/core/commands/commit/interactors/get_final_yaml.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from services.yaml import final_commit_yaml diff --git a/core/commands/commit/interactors/get_latest_upload_error.py b/core/commands/commit/interactors/get_latest_upload_error.py index e9f660a9b4..46482a71c5 100644 --- a/core/commands/commit/interactors/get_latest_upload_error.py +++ b/core/commands/commit/interactors/get_latest_upload_error.py @@ -1,8 +1,9 @@ import logging from typing import Optional +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from core.models import Commit from reports.models import CommitReport, UploadError diff --git a/core/commands/commit/interactors/get_uploads_number.py b/core/commands/commit/interactors/get_uploads_number.py index e8cd9b936c..f8c0fe8563 100644 --- a/core/commands/commit/interactors/get_uploads_number.py +++ b/core/commands/commit/interactors/get_uploads_number.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class GetUploadsNumberInteractor(BaseInteractor): diff --git a/core/commands/commit/interactors/tests/test_get_commits_errors.py b/core/commands/commit/interactors/tests/test_get_commits_errors.py index 873b934c98..6d17b3766f 100644 --- a/core/commands/commit/interactors/tests/test_get_commits_errors.py +++ b/core/commands/commit/interactors/tests/test_get_commits_errors.py @@ -1,5 +1,5 @@ from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitErrorFactory, CommitFactory, @@ -11,7 +11,7 @@ from ..get_commit_errors import GetCommitErrorsInteractor -class GetCommitErrorsInteractorTest(TransactionTestCase): +class GetCommitErrorsInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory() self.commit = CommitFactory() diff --git a/core/commands/commit/interactors/tests/test_get_file_content.py b/core/commands/commit/interactors/tests/test_get_file_content.py index ca85fabd6a..1da49c7b6c 100644 --- a/core/commands/commit/interactors/tests/test_get_file_content.py +++ b/core/commands/commit/interactors/tests/test_get_file_content.py @@ -1,7 +1,7 @@ from unittest.mock import patch import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -32,7 +32,7 @@ def function_1: } -class GetFileContentInteractorTest(TransactionTestCase): +class GetFileContentInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.repository = RepositoryFactory() diff --git a/core/commands/commit/interactors/tests/test_get_final_yaml.py b/core/commands/commit/interactors/tests/test_get_final_yaml.py index 6375964939..3a6b5bfe55 100644 --- a/core/commands/commit/interactors/tests/test_get_final_yaml.py +++ b/core/commands/commit/interactors/tests/test_get_final_yaml.py @@ -2,7 +2,7 @@ from unittest.mock import patch from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -13,7 +13,7 @@ from ..get_final_yaml import GetFinalYamlInteractor -class GetFinalYamlInteractorTest(TransactionTestCase): +class GetFinalYamlInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) diff --git a/core/commands/commit/interactors/tests/test_get_latest_upload_error.py b/core/commands/commit/interactors/tests/test_get_latest_upload_error.py index 67ce3125a8..401148bb47 100644 --- a/core/commands/commit/interactors/tests/test_get_latest_upload_error.py +++ b/core/commands/commit/interactors/tests/test_get_latest_upload_error.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -19,7 +19,7 @@ ) -class GetLatestUploadErrorInteractorTest(TransactionTestCase): +class GetLatestUploadErrorInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org) diff --git a/core/commands/commit/interactors/tests/test_get_uploads_number.py b/core/commands/commit/interactors/tests/test_get_uploads_number.py index 8a01987cdd..c19fcc5b18 100644 --- a/core/commands/commit/interactors/tests/test_get_uploads_number.py +++ b/core/commands/commit/interactors/tests/test_get_uploads_number.py @@ -1,5 +1,5 @@ from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory from reports.tests.factories import UploadFactory @@ -7,7 +7,7 @@ from ..get_uploads_number import GetUploadsNumberInteractor -class GetUploadsNumberInteractorTest(TransactionTestCase): +class GetUploadsNumberInteractorTest(TestCase): def setUp(self): self.commit_with_no_upload = CommitFactory() self.upload_one = UploadFactory() diff --git a/core/commands/commit/tests/test_commit.py b/core/commands/commit/tests/test_commit.py index 3a1364c652..2e0f11f090 100644 --- a/core/commands/commit/tests/test_commit.py +++ b/core/commands/commit/tests/test_commit.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -11,7 +11,7 @@ from ..commit import CommitCommands -class CommitCommandsTest(TransactionTestCase): +class CommitCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.repository = RepositoryFactory() diff --git a/core/commands/component/tests/test_component.py b/core/commands/component/tests/test_component.py index 61882d7b98..c2605dc862 100644 --- a/core/commands/component/tests/test_component.py +++ b/core/commands/component/tests/test_component.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError @@ -13,7 +13,7 @@ def apply_async(self): pass -class ComponentCommandsTest(TransactionTestCase): +class ComponentCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="test-user") self.org = OwnerFactory(username="test-org", admins=[self.owner.pk]) diff --git a/core/commands/flag/tests/test_flag.py b/core/commands/flag/tests/test_flag.py index 51c3e5adcd..66f12ac43f 100644 --- a/core/commands/flag/tests/test_flag.py +++ b/core/commands/flag/tests/test_flag.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from codecov.commands.exceptions import ( @@ -14,7 +14,7 @@ from ..flag import FlagCommands -class FlagCommandsTest(TransactionTestCase): +class FlagCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="test-user") self.org = OwnerFactory(username="test-org", admins=[self.owner.pk]) diff --git a/core/commands/pull/interactors/fetch_pull_request.py b/core/commands/pull/interactors/fetch_pull_request.py index a5f0dafc85..b60a310f0f 100644 --- a/core/commands/pull/interactors/fetch_pull_request.py +++ b/core/commands/pull/interactors/fetch_pull_request.py @@ -1,9 +1,9 @@ from datetime import datetime, timedelta +from asgiref.sync import sync_to_async from shared.django_apps.core.models import Pull, Repository from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from services.task.task import TaskService diff --git a/core/commands/pull/interactors/fetch_pull_requests.py b/core/commands/pull/interactors/fetch_pull_requests.py index 8c5623304e..bc67abcf51 100644 --- a/core/commands/pull/interactors/fetch_pull_requests.py +++ b/core/commands/pull/interactors/fetch_pull_requests.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class FetchPullRequestsInteractor(BaseInteractor): diff --git a/core/commands/pull/interactors/tests/test_fetch_pull_request.py b/core/commands/pull/interactors/tests/test_fetch_pull_request.py index f01539e330..18bbb860b7 100644 --- a/core/commands/pull/interactors/tests/test_fetch_pull_request.py +++ b/core/commands/pull/interactors/tests/test_fetch_pull_request.py @@ -1,7 +1,7 @@ from datetime import datetime import pytest -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from shared.django_apps.core.tests.factories import ( OwnerFactory, @@ -12,7 +12,7 @@ from ..fetch_pull_request import FetchPullRequestInteractor -class FetchPullRequestInteractorTest(TransactionTestCase): +class FetchPullRequestInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) @@ -32,7 +32,6 @@ async def test_fetch_pull_request(self): assert pr == self.pr -# Not part of the class because TransactionTestCase cannot be parametrized @freeze_time("2024-07-01 12:00:00") @pytest.mark.parametrize( "pr_state, updatestamp, expected", diff --git a/core/commands/pull/interactors/tests/test_fetch_pull_requests.py b/core/commands/pull/interactors/tests/test_fetch_pull_requests.py index 61afa47d3e..f511566fbc 100644 --- a/core/commands/pull/interactors/tests/test_fetch_pull_requests.py +++ b/core/commands/pull/interactors/tests/test_fetch_pull_requests.py @@ -1,5 +1,5 @@ from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( OwnerFactory, PullFactory, @@ -11,7 +11,7 @@ from ..fetch_pull_requests import FetchPullRequestsInteractor -class FetchPullRequestsInteractorTest(TransactionTestCase): +class FetchPullRequestsInteractorTest(TestCase): def setUp(self): self.pull_id = 10 self.pull_title = "test-open-pr-1" diff --git a/core/commands/pull/tests/test_pull.py b/core/commands/pull/tests/test_pull.py index 6ee15a44fd..5caf12873d 100644 --- a/core/commands/pull/tests/test_pull.py +++ b/core/commands/pull/tests/test_pull.py @@ -1,12 +1,12 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from ..pull import PullCommands -class PullCommandsTest(TransactionTestCase): +class PullCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.repository = RepositoryFactory() diff --git a/core/commands/repository/interactors/activate_measurements.py b/core/commands/repository/interactors/activate_measurements.py index 4aebb7116a..f91881b044 100644 --- a/core/commands/repository/interactors/activate_measurements.py +++ b/core/commands/repository/interactors/activate_measurements.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from django.conf import settings from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from timeseries.helpers import trigger_backfill from timeseries.models import Dataset, MeasurementName diff --git a/core/commands/repository/interactors/encode_secret_string.py b/core/commands/repository/interactors/encode_secret_string.py index 25e6bc2fbb..94bceed919 100644 --- a/core/commands/repository/interactors/encode_secret_string.py +++ b/core/commands/repository/interactors/encode_secret_string.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, ValidationError -from codecov.db import sync_to_async from codecov_auth.models import Owner from core.commands.repository.interactors.utils import encode_secret_string from core.models import Repository diff --git a/core/commands/repository/interactors/erase_repository.py b/core/commands/repository/interactors/erase_repository.py index 5398740748..804580bed8 100644 --- a/core/commands/repository/interactors/erase_repository.py +++ b/core/commands/repository/interactors/erase_repository.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from services.task.task import TaskService diff --git a/core/commands/repository/interactors/fetch_repository.py b/core/commands/repository/interactors/fetch_repository.py index 0993e959c5..99961c3bd3 100644 --- a/core/commands/repository/interactors/fetch_repository.py +++ b/core/commands/repository/interactors/fetch_repository.py @@ -1,8 +1,8 @@ +from asgiref.sync import sync_to_async from shared.django_apps.codecov_auth.models import Owner from shared.django_apps.core.models import Repository from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class FetchRepositoryInteractor(BaseInteractor): diff --git a/core/commands/repository/interactors/get_repository_token.py b/core/commands/repository/interactors/get_repository_token.py index 55cd13b952..361b83b914 100644 --- a/core/commands/repository/interactors/get_repository_token.py +++ b/core/commands/repository/interactors/get_repository_token.py @@ -1,6 +1,7 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import RepositoryToken diff --git a/core/commands/repository/interactors/regenerate_repository_token.py b/core/commands/repository/interactors/regenerate_repository_token.py index ebd6197cbf..9d02738e2c 100644 --- a/core/commands/repository/interactors/regenerate_repository_token.py +++ b/core/commands/repository/interactors/regenerate_repository_token.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from codecov_auth.models import RepositoryToken diff --git a/core/commands/repository/interactors/regenerate_repository_upload_token.py b/core/commands/repository/interactors/regenerate_repository_upload_token.py index ee02faff2c..885f3955b6 100644 --- a/core/commands/repository/interactors/regenerate_repository_upload_token.py +++ b/core/commands/repository/interactors/regenerate_repository_upload_token.py @@ -1,7 +1,8 @@ import uuid +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async class RegenerateRepositoryUploadTokenInteractor(BaseInteractor): diff --git a/core/commands/repository/interactors/tests/test_activate_measurements.py b/core/commands/repository/interactors/tests/test_activate_measurements.py index c1e0478171..0c96a7fb1d 100644 --- a/core/commands/repository/interactors/tests/test_activate_measurements.py +++ b/core/commands/repository/interactors/tests/test_activate_measurements.py @@ -4,7 +4,7 @@ import pytest from asgiref.sync import async_to_sync from django.conf import settings -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from freezegun import freeze_time from shared.django_apps.core.tests.factories import ( @@ -22,7 +22,7 @@ @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class ActivateMeasurementsInteractorTest(TransactionTestCase): +class ActivateMeasurementsInteractorTest(TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/core/commands/repository/interactors/tests/test_encode_secret_string.py b/core/commands/repository/interactors/tests/test_encode_secret_string.py index f0606da4e2..2b5f8e1b63 100644 --- a/core/commands/repository/interactors/tests/test_encode_secret_string.py +++ b/core/commands/repository/interactors/tests/test_encode_secret_string.py @@ -1,6 +1,6 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from shared.encryption.yaml_secret import yaml_secret_encryptor @@ -9,7 +9,7 @@ from ..encode_secret_string import EncodeSecretStringInteractor -class EncodeSecretStringInteractorTest(TransactionTestCase): +class EncodeSecretStringInteractorTest(TestCase): @async_to_sync def execute(self, owner, repo_name, value): return EncodeSecretStringInteractor(owner, "github").execute( diff --git a/core/commands/repository/interactors/tests/test_erase_repository.py b/core/commands/repository/interactors/tests/test_erase_repository.py index f0863244bf..aed9fde9a8 100644 --- a/core/commands/repository/interactors/tests/test_erase_repository.py +++ b/core/commands/repository/interactors/tests/test_erase_repository.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthorized @@ -7,7 +7,7 @@ from ..erase_repository import EraseRepositoryInteractor -class UpdateRepositoryInteractorTest(TransactionTestCase): +class UpdateRepositoryInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov") self.random_user = OwnerFactory(organizations=[]) diff --git a/core/commands/repository/interactors/tests/test_fetch_repository.py b/core/commands/repository/interactors/tests/test_fetch_repository.py index 25865a4aa0..e250ba98d3 100644 --- a/core/commands/repository/interactors/tests/test_fetch_repository.py +++ b/core/commands/repository/interactors/tests/test_fetch_repository.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( AccountFactory, OktaSettingsFactory, @@ -8,7 +8,7 @@ from ..fetch_repository import FetchRepositoryInteractor -class FetchRepositoryInteractorTest(TransactionTestCase): +class FetchRepositoryInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() diff --git a/core/commands/repository/interactors/tests/test_get_repository_token.py b/core/commands/repository/interactors/tests/test_get_repository_token.py index a552ac36ec..f634667dd3 100644 --- a/core/commands/repository/interactors/tests/test_get_repository_token.py +++ b/core/commands/repository/interactors/tests/test_get_repository_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( OwnerFactory, RepositoryFactory, @@ -11,7 +11,7 @@ from ..get_repository_token import GetRepositoryTokenInteractor -class GetRepositoryTokenInteractorTest(TransactionTestCase): +class GetRepositoryTokenInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory(name="codecov") self.active_repo = RepositoryFactory( diff --git a/core/commands/repository/interactors/tests/test_get_upload_token.py b/core/commands/repository/interactors/tests/test_get_upload_token.py index d7b0da260a..2f165461d6 100644 --- a/core/commands/repository/interactors/tests/test_get_upload_token.py +++ b/core/commands/repository/interactors/tests/test_get_upload_token.py @@ -1,10 +1,10 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from ..get_upload_token import GetUploadTokenInteractor -class GetUploadTokenInteractorTest(TransactionTestCase): +class GetUploadTokenInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo_in_org = RepositoryFactory(author=self.org) diff --git a/core/commands/repository/interactors/tests/test_regenerate_repository_token.py b/core/commands/repository/interactors/tests/test_regenerate_repository_token.py index 5f5a7f2a0f..6519e6aaf4 100644 --- a/core/commands/repository/interactors/tests/test_regenerate_repository_token.py +++ b/core/commands/repository/interactors/tests/test_regenerate_repository_token.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( OwnerFactory, RepositoryFactory, @@ -11,7 +11,7 @@ from ..regenerate_repository_token import RegenerateRepositoryTokenInteractor -class RegenerateRepositoryTokenInteractorTest(TransactionTestCase): +class RegenerateRepositoryTokenInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.active_repo = RepositoryFactory( diff --git a/core/commands/repository/interactors/tests/test_update_bundle_cache_config.py b/core/commands/repository/interactors/tests/test_update_bundle_cache_config.py index 19270f10cd..50cd14c90e 100644 --- a/core/commands/repository/interactors/tests/test_update_bundle_cache_config.py +++ b/core/commands/repository/interactors/tests/test_update_bundle_cache_config.py @@ -1,6 +1,6 @@ import pytest from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.bundle_analysis.models import CacheConfig from shared.django_apps.core.tests.factories import ( OwnerFactory, @@ -12,7 +12,7 @@ from ..update_bundle_cache_config import UpdateBundleCacheConfigInteractor -class UpdateBundleCacheConfigInteractorTest(TransactionTestCase): +class UpdateBundleCacheConfigInteractorTest(TestCase): databases = {"default"} def setUp(self): diff --git a/core/commands/repository/interactors/tests/test_update_repository.py b/core/commands/repository/interactors/tests/test_update_repository.py index 0192d89f62..df8bf7db44 100644 --- a/core/commands/repository/interactors/tests/test_update_repository.py +++ b/core/commands/repository/interactors/tests/test_update_repository.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov.commands.exceptions import Unauthorized @@ -7,7 +7,7 @@ from ..update_repository import UpdateRepositoryInteractor -class UpdateRepositoryInteractorTest(TransactionTestCase): +class UpdateRepositoryInteractorTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov") self.random_user = OwnerFactory(organizations=[]) diff --git a/core/commands/repository/interactors/update_bundle_cache_config.py b/core/commands/repository/interactors/update_bundle_cache_config.py index 544a9b6509..812d6ffa32 100644 --- a/core/commands/repository/interactors/update_bundle_cache_config.py +++ b/core/commands/repository/interactors/update_bundle_cache_config.py @@ -1,5 +1,6 @@ from typing import Dict, List +from asgiref.sync import sync_to_async from shared.django_apps.bundle_analysis.models import CacheConfig from shared.django_apps.bundle_analysis.service.bundle_analysis import ( BundleAnalysisCacheConfigService, @@ -7,7 +8,6 @@ from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from core.models import Repository diff --git a/core/commands/repository/interactors/update_repository.py b/core/commands/repository/interactors/update_repository.py index d455da85c5..4fbe12d9a0 100644 --- a/core/commands/repository/interactors/update_repository.py +++ b/core/commands/repository/interactors/update_repository.py @@ -1,8 +1,9 @@ from typing import Optional +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError -from codecov.db import sync_to_async from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import Owner from core.models import Repository diff --git a/core/commands/repository/tests/test_repository.py b/core/commands/repository/tests/test_repository.py index 8d5b8077ef..407e54a5a5 100644 --- a/core/commands/repository/tests/test_repository.py +++ b/core/commands/repository/tests/test_repository.py @@ -1,13 +1,13 @@ from unittest.mock import patch from django.contrib.auth.models import AnonymousUser -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from ..repository import RepositoryCommands -class RepositoryCommandsTest(TransactionTestCase): +class RepositoryCommandsTest(TestCase): def setUp(self): self.user = AnonymousUser() self.org = OwnerFactory(username="codecov") diff --git a/core/commands/upload/interactors/get_upload_error.py b/core/commands/upload/interactors/get_upload_error.py index aa4a6d1e5b..9b9d72ed4d 100644 --- a/core/commands/upload/interactors/get_upload_error.py +++ b/core/commands/upload/interactors/get_upload_error.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.base import BaseInteractor -from codecov.db import sync_to_async from graphql_api.types.enums import UploadState from reports.models import UploadError diff --git a/core/commands/upload/interactors/tests/test_upload_error.py b/core/commands/upload/interactors/tests/test_upload_error.py index 68477013b0..95a22377f2 100644 --- a/core/commands/upload/interactors/tests/test_upload_error.py +++ b/core/commands/upload/interactors/tests/test_upload_error.py @@ -1,5 +1,5 @@ from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -16,7 +16,7 @@ from ..get_upload_error import GetUploadErrorInteractor -class GetUploadErrorInteractorTest(TransactionTestCase): +class GetUploadErrorInteractorTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) diff --git a/core/commands/upload/tests/test_upload.py b/core/commands/upload/tests/test_upload.py index 404ff3d236..eb93c4e833 100644 --- a/core/commands/upload/tests/test_upload.py +++ b/core/commands/upload/tests/test_upload.py @@ -1,12 +1,12 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory, OwnerFactory from ..upload import UploadCommands -class UploadCommandsTest(TransactionTestCase): +class UploadCommandsTest(TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.report_session = CommitFactory() diff --git a/graphql_api/actions/owner.py b/graphql_api/actions/owner.py index 5514393162..8f5b7580cd 100644 --- a/graphql_api/actions/owner.py +++ b/graphql_api/actions/owner.py @@ -1,5 +1,6 @@ +from asgiref.sync import sync_to_async + from codecov.commands.exceptions import MissingService -from codecov.db import sync_to_async from codecov_auth.models import Owner from utils.services import get_long_service_name diff --git a/graphql_api/dataloader/comparison.py b/graphql_api/dataloader/comparison.py index c1b1bc953b..eadfa66f16 100644 --- a/graphql_api/dataloader/comparison.py +++ b/graphql_api/dataloader/comparison.py @@ -1,6 +1,7 @@ import logging -from codecov.db import sync_to_async +from asgiref.sync import sync_to_async + from compare.models import CommitComparison from core.models import Commit from services.comparison import CommitComparisonService diff --git a/graphql_api/dataloader/loader.py b/graphql_api/dataloader/loader.py index 95c0c7b392..8f26e9986c 100644 --- a/graphql_api/dataloader/loader.py +++ b/graphql_api/dataloader/loader.py @@ -1,6 +1,5 @@ from aiodataloader import DataLoader - -from codecov.db import sync_to_async +from asgiref.sync import sync_to_async class BaseLoader(DataLoader): diff --git a/graphql_api/dataloader/tests/test_bundle_analysis.py b/graphql_api/dataloader/tests/test_bundle_analysis.py index 02ca19c167..1f7b27ea23 100644 --- a/graphql_api/dataloader/tests/test_bundle_analysis.py +++ b/graphql_api/dataloader/tests/test_bundle_analysis.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory, RepositoryFactory from graphql_api.dataloader.bundle_analysis import ( @@ -44,7 +44,7 @@ def __init__(self): raise MissingBaseReportError() -class BundleAnalysisComparisonLoader(TransactionTestCase): +class BundleAnalysisComparisonLoader(TestCase): def setUp(self): self.repo = RepositoryFactory() @@ -126,7 +126,7 @@ def test_loader_raises_missing_base_report(self): assert loader.message == MissingBaseReport.message -class BundleAnalysisReportLoader(TransactionTestCase): +class BundleAnalysisReportLoader(TestCase): def setUp(self): self.repo = RepositoryFactory() diff --git a/graphql_api/dataloader/tests/test_commit.py b/graphql_api/dataloader/tests/test_commit.py index 24c1ec4cca..5e8b7a9485 100644 --- a/graphql_api/dataloader/tests/test_commit.py +++ b/graphql_api/dataloader/tests/test_commit.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, PullFactory, @@ -13,7 +13,7 @@ def __init__(self): self.context = {} -class CommitLoaderTestCase(TransactionTestCase): +class CommitLoaderTestCase(TestCase): def setUp(self): self.repository = RepositoryFactory(name="test-repo-1") self.pull_1_commit = CommitFactory( diff --git a/graphql_api/dataloader/tests/test_comparison.py b/graphql_api/dataloader/tests/test_comparison.py index 42a5afd9a0..c5ea12c433 100644 --- a/graphql_api/dataloader/tests/test_comparison.py +++ b/graphql_api/dataloader/tests/test_comparison.py @@ -1,7 +1,7 @@ from unittest.mock import patch from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory, RepositoryFactory from compare.models import CommitComparison @@ -21,7 +21,7 @@ async def load_comparisons(repoid, keys): @patch("services.task.TaskService.compute_comparisons") -class ComparisonLoaderTestCase(TransactionTestCase): +class ComparisonLoaderTestCase(TestCase): def setUp(self): self.repository = RepositoryFactory(name="test-repo-1") diff --git a/graphql_api/dataloader/tests/test_loader.py b/graphql_api/dataloader/tests/test_loader.py index 388b0c6c5f..00d6939c04 100644 --- a/graphql_api/dataloader/tests/test_loader.py +++ b/graphql_api/dataloader/tests/test_loader.py @@ -1,5 +1,5 @@ import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory from graphql_api.dataloader.loader import BaseLoader @@ -10,7 +10,7 @@ def __init__(self): self.context = {} -class BaseLoaderTestCase(TransactionTestCase): +class BaseLoaderTestCase(TestCase): def setUp(self): # record type is irrelevant here self.record = CommitFactory(message="test commit", commitid="123") diff --git a/graphql_api/dataloader/tests/test_owner.py b/graphql_api/dataloader/tests/test_owner.py index 717ffdd210..3b6478ad7b 100644 --- a/graphql_api/dataloader/tests/test_owner.py +++ b/graphql_api/dataloader/tests/test_owner.py @@ -1,6 +1,6 @@ import asyncio -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.dataloader.owner import OwnerLoader @@ -11,7 +11,7 @@ def __init__(self): self.context = {} -class OnwerLoaderTestCase(TransactionTestCase): +class OnwerLoaderTestCase(TestCase): def setUp(self): self.users = [ OwnerFactory(username="codecov-1"), diff --git a/graphql_api/helpers/connection.py b/graphql_api/helpers/connection.py index bfb5d78b9f..5eb3222604 100644 --- a/graphql_api/helpers/connection.py +++ b/graphql_api/helpers/connection.py @@ -4,11 +4,11 @@ from functools import cached_property from typing import Any, Dict, List, Optional +from asgiref.sync import sync_to_async from cursor_pagination import CursorPage, CursorPaginator, InvalidCursor from django.db.models import QuerySet from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from graphql_api.types.enums import OrderingDirection diff --git a/graphql_api/helpers/tests/test_connection.py b/graphql_api/helpers/tests/test_connection.py index 35dd284e60..fea9512cb0 100644 --- a/graphql_api/helpers/tests/test_connection.py +++ b/graphql_api/helpers/tests/test_connection.py @@ -1,5 +1,5 @@ from asgiref.sync import async_to_sync -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import RepositoryFactory from codecov.commands.exceptions import ValidationError @@ -7,7 +7,7 @@ from graphql_api.types.enums import OrderingDirection, RepositoryOrdering -class RepositoryQuerySetTests(TransactionTestCase): +class RepositoryQuerySetTests(TestCase): def test_queryset_to_connection_deterministic_ordering(self): from graphql_api.helpers.connection import queryset_to_connection diff --git a/graphql_api/helpers/tests/test_mutation.py b/graphql_api/helpers/tests/test_mutation.py index 2b118f8469..b2d656a7c0 100644 --- a/graphql_api/helpers/tests/test_mutation.py +++ b/graphql_api/helpers/tests/test_mutation.py @@ -1,3 +1,4 @@ +from asgiref.sync import sync_to_async from django.test import SimpleTestCase from codecov.commands.exceptions import ( @@ -6,7 +7,6 @@ Unauthorized, ValidationError, ) -from codecov.db import sync_to_async from ..mutation import resolve_union_error_type, wrap_error_handling_mutation diff --git a/graphql_api/tests/actions/test_commits.py b/graphql_api/tests/actions/test_commits.py index 8b0b3cb6cf..742c94960f 100644 --- a/graphql_api/tests/actions/test_commits.py +++ b/graphql_api/tests/actions/test_commits.py @@ -1,6 +1,6 @@ from collections import Counter -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -12,7 +12,7 @@ from reports.tests.factories import CommitReportFactory, UploadFactory -class RepoCommitsTests(TransactionTestCase): +class RepoCommitsTests(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) diff --git a/graphql_api/tests/mutation/test_activate_measurements.py b/graphql_api/tests/mutation/test_activate_measurements.py index 52aefa0f96..ee3a978f7e 100644 --- a/graphql_api/tests/mutation/test_activate_measurements.py +++ b/graphql_api/tests/mutation/test_activate_measurements.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -16,7 +16,7 @@ """ -class ActivateMeasurementsTestCase(GraphQLTestHelper, TransactionTestCase): +class ActivateMeasurementsTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory() diff --git a/graphql_api/tests/mutation/test_cancel_trial.py b/graphql_api/tests/mutation/test_cancel_trial.py index cb5d39dc8a..65b09c565d 100644 --- a/graphql_api/tests/mutation/test_cancel_trial.py +++ b/graphql_api/tests/mutation/test_cancel_trial.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from prometheus_client import REGISTRY from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory from shared.django_apps.core.tests.factories import OwnerFactory @@ -21,7 +21,7 @@ """ -class CancelTrialMutationTest(GraphQLTestHelper, TransactionTestCase): +class CancelTrialMutationTest(GraphQLTestHelper, TestCase): def _request(self, owner=None, org_username: str = None): return self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_create_api_token.py b/graphql_api/tests/mutation/test_create_api_token.py index 8cecc3d21f..1b0cfa264f 100644 --- a/graphql_api/tests/mutation/test_create_api_token.py +++ b/graphql_api/tests/mutation/test_create_api_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov_auth.models import Session @@ -24,7 +24,7 @@ """ -class CreateApiTokenTestCase(GraphQLTestHelper, TransactionTestCase): +class CreateApiTokenTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/mutation/test_create_stripe_setup_intent.py b/graphql_api/tests/mutation/test_create_stripe_setup_intent.py index 609d84f579..9143e51374 100644 --- a/graphql_api/tests/mutation/test_create_stripe_setup_intent.py +++ b/graphql_api/tests/mutation/test_create_stripe_setup_intent.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -17,7 +17,7 @@ """ -class CreateStripeSetupIntentTestCase(GraphQLTestHelper, TransactionTestCase): +class CreateStripeSetupIntentTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/mutation/test_create_user_token.py b/graphql_api/tests/mutation/test_create_user_token.py index 1c45d1aa98..721ee15f25 100644 --- a/graphql_api/tests/mutation/test_create_user_token.py +++ b/graphql_api/tests/mutation/test_create_user_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov_auth.models import UserToken @@ -22,7 +22,7 @@ """ -class CreateApiTokenTestCase(GraphQLTestHelper, TransactionTestCase): +class CreateApiTokenTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/mutation/test_delete_component_measurements.py b/graphql_api/tests/mutation/test_delete_component_measurements.py index 0e090a0bb3..a01417e4f8 100644 --- a/graphql_api/tests/mutation/test_delete_component_measurements.py +++ b/graphql_api/tests/mutation/test_delete_component_measurements.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from codecov.commands.exceptions import ( NotFound, @@ -24,7 +24,7 @@ """ -class DeleteComponentMeasurementsTest(GraphQLTestHelper, TransactionTestCase): +class DeleteComponentMeasurementsTest(GraphQLTestHelper, TestCase): @patch( "core.commands.component.interactors.delete_component_measurements.DeleteComponentMeasurementsInteractor.execute" ) diff --git a/graphql_api/tests/mutation/test_delete_flag.py b/graphql_api/tests/mutation/test_delete_flag.py index a2522ed5e5..a5649c8347 100644 --- a/graphql_api/tests/mutation/test_delete_flag.py +++ b/graphql_api/tests/mutation/test_delete_flag.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from codecov.commands.exceptions import ( NotFound, @@ -24,7 +24,7 @@ """ -class DeleteFlagTest(GraphQLTestHelper, TransactionTestCase): +class DeleteFlagTest(GraphQLTestHelper, TestCase): @patch("core.commands.flag.interactors.delete_flag.DeleteFlagInteractor.execute") def test_delete_flag(self, execute_mock): data = self.gql_request( diff --git a/graphql_api/tests/mutation/test_delete_session.py b/graphql_api/tests/mutation/test_delete_session.py index b2b574c16d..2486b4ef20 100644 --- a/graphql_api/tests/mutation/test_delete_session.py +++ b/graphql_api/tests/mutation/test_delete_session.py @@ -30,6 +30,9 @@ def test_when_authenticated(self): self.owner.user = user self.owner.save() + django_session_id = DjangoSession.objects.all() + assert len(django_session_id) == 0 + login_query = "{ me { user { username }} }" self.gql_request(login_query, owner=self.owner) diff --git a/graphql_api/tests/mutation/test_encode_secret_string.py b/graphql_api/tests/mutation/test_encode_secret_string.py index f8092c1875..e7f50c4393 100644 --- a/graphql_api/tests/mutation/test_encode_secret_string.py +++ b/graphql_api/tests/mutation/test_encode_secret_string.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from shared.encryption.yaml_secret import yaml_secret_encryptor @@ -19,7 +19,7 @@ """ -class TestEncodeSecretString(TransactionTestCase, GraphQLTestHelper): +class TestEncodeSecretString(TestCase, GraphQLTestHelper): def _request(self): data = self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_erase_repository.py b/graphql_api/tests/mutation/test_erase_repository.py index 0f455e12b5..5c69e7d47c 100644 --- a/graphql_api/tests/mutation/test_erase_repository.py +++ b/graphql_api/tests/mutation/test_erase_repository.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -19,7 +19,7 @@ """ -class EraseRepositoryTests(GraphQLTestHelper, TransactionTestCase): +class EraseRepositoryTests(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov", service="github") self.non_admin_user = OwnerFactory(organizations=[self.org.ownerid]) diff --git a/graphql_api/tests/mutation/test_regenerate_repository_token.py b/graphql_api/tests/mutation/test_regenerate_repository_token.py index 27df71a18a..8bfd8f7675 100644 --- a/graphql_api/tests/mutation/test_regenerate_repository_token.py +++ b/graphql_api/tests/mutation/test_regenerate_repository_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( OwnerFactory, RepositoryFactory, @@ -22,7 +22,7 @@ """ -class RegeneratRepositoryTokenTests(GraphQLTestHelper, TransactionTestCase): +class RegeneratRepositoryTokenTests(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory(author=self.org, name="gazebo", active=True) diff --git a/graphql_api/tests/mutation/test_regenerate_repository_upload_token.py b/graphql_api/tests/mutation/test_regenerate_repository_upload_token.py index 005e256a69..b1e74b61b1 100644 --- a/graphql_api/tests/mutation/test_regenerate_repository_upload_token.py +++ b/graphql_api/tests/mutation/test_regenerate_repository_upload_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -18,7 +18,7 @@ """ -class RegenerateRepositoryUploadTokenTests(GraphQLTestHelper, TransactionTestCase): +class RegenerateRepositoryUploadTokenTests(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory(author=self.org, name="gazebo") diff --git a/graphql_api/tests/mutation/test_regenrate_org_upload_token.py b/graphql_api/tests/mutation/test_regenrate_org_upload_token.py index 1c801c26d6..0819539699 100644 --- a/graphql_api/tests/mutation/test_regenrate_org_upload_token.py +++ b/graphql_api/tests/mutation/test_regenrate_org_upload_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -15,7 +15,7 @@ """ -class RegenerateOrgUploadToken(GraphQLTestHelper, TransactionTestCase): +class RegenerateOrgUploadToken(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory( username="codecov", plan="users-enterprisem", service="github" diff --git a/graphql_api/tests/mutation/test_revoke_user_token.py b/graphql_api/tests/mutation/test_revoke_user_token.py index f0c84a9c73..0c3d020e60 100644 --- a/graphql_api/tests/mutation/test_revoke_user_token.py +++ b/graphql_api/tests/mutation/test_revoke_user_token.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( OwnerFactory, UserTokenFactory, @@ -17,7 +17,7 @@ """ -class RevokeUserTokenTestCase(GraphQLTestHelper, TransactionTestCase): +class RevokeUserTokenTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/mutation/test_save_okta_config.py b/graphql_api/tests/mutation/test_save_okta_config.py index b3c63cdd0d..7d85232b69 100644 --- a/graphql_api/tests/mutation/test_save_okta_config.py +++ b/graphql_api/tests/mutation/test_save_okta_config.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import AccountFactory, OwnerFactory from codecov_auth.models import OktaSettings @@ -15,7 +15,7 @@ """ -class SaveOktaConfigTestCase(GraphQLTestHelper, TransactionTestCase): +class SaveOktaConfigTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.current_user = OwnerFactory(username="codecov-user") self.owner = OwnerFactory( diff --git a/graphql_api/tests/mutation/test_save_sentry_state.py b/graphql_api/tests/mutation/test_save_sentry_state.py index 51c190389a..d7713e7363 100644 --- a/graphql_api/tests/mutation/test_save_sentry_state.py +++ b/graphql_api/tests/mutation/test_save_sentry_state.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -21,7 +21,7 @@ @patch("services.sentry.save_sentry_state") -class SaveSentryStateMutationTest(GraphQLTestHelper, TransactionTestCase): +class SaveSentryStateMutationTest(GraphQLTestHelper, TestCase): def _request(self, owner=None): return self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_save_terms_agreement.py b/graphql_api/tests/mutation/test_save_terms_agreement.py index a647e37b8a..a4d854066e 100644 --- a/graphql_api/tests/mutation/test_save_terms_agreement.py +++ b/graphql_api/tests/mutation/test_save_terms_agreement.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -17,7 +17,7 @@ """ -class SaveTermsAgreementMutationTest(GraphQLTestHelper, TransactionTestCase): +class SaveTermsAgreementMutationTest(GraphQLTestHelper, TestCase): def _request_deprecated(self, owner=None): return self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_set_upload_token_required.py b/graphql_api/tests/mutation/test_set_upload_token_required.py index 357b227af7..fa729c9507 100644 --- a/graphql_api/tests/mutation/test_set_upload_token_required.py +++ b/graphql_api/tests/mutation/test_set_upload_token_required.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -17,7 +17,7 @@ """ -class SetUploadTokenRequiredTests(GraphQLTestHelper, TransactionTestCase): +class SetUploadTokenRequiredTests(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") diff --git a/graphql_api/tests/mutation/test_set_yaml_on_owner.py b/graphql_api/tests/mutation/test_set_yaml_on_owner.py index e0557feae7..ed4f153b13 100644 --- a/graphql_api/tests/mutation/test_set_yaml_on_owner.py +++ b/graphql_api/tests/mutation/test_set_yaml_on_owner.py @@ -1,7 +1,7 @@ import asyncio from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -20,7 +20,7 @@ """ -class SetYamlOnOwnerMutationTest(GraphQLTestHelper, TransactionTestCase): +class SetYamlOnOwnerMutationTest(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") asyncio.set_event_loop(asyncio.new_event_loop()) diff --git a/graphql_api/tests/mutation/test_start_trial.py b/graphql_api/tests/mutation/test_start_trial.py index ffe033d218..92e3ba5330 100644 --- a/graphql_api/tests/mutation/test_start_trial.py +++ b/graphql_api/tests/mutation/test_start_trial.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -17,7 +17,7 @@ """ -class StartTrialMutationTest(GraphQLTestHelper, TransactionTestCase): +class StartTrialMutationTest(GraphQLTestHelper, TestCase): def _request(self, owner=None, org_username: str = None): return self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_store_codecov_metrics.py b/graphql_api/tests/mutation/test_store_codecov_metrics.py index 7db4d7876d..7976d8d70a 100644 --- a/graphql_api/tests/mutation/test_store_codecov_metrics.py +++ b/graphql_api/tests/mutation/test_store_codecov_metrics.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_metrics.models import UserOnboardingLifeCycleMetrics from shared.django_apps.core.tests.factories import OwnerFactory @@ -18,7 +18,7 @@ """ -class StoreEventMetricMutationTest(GraphQLTestHelper, TransactionTestCase): +class StoreEventMetricMutationTest(GraphQLTestHelper, TestCase): def _request(self, org_username: str, event: str, json_payload: str, owner=None): return self.gql_request( query, diff --git a/graphql_api/tests/mutation/test_update_bundle_cache_config.py b/graphql_api/tests/mutation/test_update_bundle_cache_config.py index 10b8b68c22..53256f40f0 100644 --- a/graphql_api/tests/mutation/test_update_bundle_cache_config.py +++ b/graphql_api/tests/mutation/test_update_bundle_cache_config.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -46,7 +46,7 @@ """ -class UpdateBundleCacheConfigTestCase(GraphQLTestHelper, TransactionTestCase): +class UpdateBundleCacheConfigTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory() diff --git a/graphql_api/tests/mutation/test_update_default_organization.py b/graphql_api/tests/mutation/test_update_default_organization.py index 2c436f9cc5..caf79cbdaf 100644 --- a/graphql_api/tests/mutation/test_update_default_organization.py +++ b/graphql_api/tests/mutation/test_update_default_organization.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from codecov_auth.models import OwnerProfile @@ -15,7 +15,7 @@ """ -class UpdateProfileTestCase(GraphQLTestHelper, TransactionTestCase): +class UpdateProfileTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.default_organization_username = "sample-default-org-username" self.default_organization = OwnerFactory( diff --git a/graphql_api/tests/mutation/test_update_profile.py b/graphql_api/tests/mutation/test_update_profile.py index ff577ab55a..615e196e45 100644 --- a/graphql_api/tests/mutation/test_update_profile.py +++ b/graphql_api/tests/mutation/test_update_profile.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -20,7 +20,7 @@ """ -class UpdateProfileTestCase(GraphQLTestHelper, TransactionTestCase): +class UpdateProfileTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/mutation/test_update_repository.py b/graphql_api/tests/mutation/test_update_repository.py index e04dc5ecbd..067879b486 100644 --- a/graphql_api/tests/mutation/test_update_repository.py +++ b/graphql_api/tests/mutation/test_update_repository.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( BranchFactory, OwnerFactory, @@ -35,7 +35,7 @@ """ -class UpdateRepositoryTests(GraphQLTestHelper, TransactionTestCase): +class UpdateRepositoryTests(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov", service="github") self.repo = RepositoryFactory(author=self.org, name="gazebo", activated=False) diff --git a/graphql_api/tests/mutation/test_update_self_hosted_settings.py b/graphql_api/tests/mutation/test_update_self_hosted_settings.py index e50be62704..e2b6b4bfad 100644 --- a/graphql_api/tests/mutation/test_update_self_hosted_settings.py +++ b/graphql_api/tests/mutation/test_update_self_hosted_settings.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper @@ -17,7 +17,7 @@ """ -class UpdateSelfHostedSettingsTest(GraphQLTestHelper, TransactionTestCase): +class UpdateSelfHostedSettingsTest(GraphQLTestHelper, TestCase): def _request(self, owner=None): return self.gql_request( query, diff --git a/graphql_api/tests/test_account.py b/graphql_api/tests/test_account.py index 38677acee9..e0ea0f030c 100644 --- a/graphql_api/tests/test_account.py +++ b/graphql_api/tests/test_account.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( AccountFactory, AccountsUsersFactory, @@ -9,7 +9,7 @@ from .helper import GraphQLTestHelper -class AccountTestCase(GraphQLTestHelper, TransactionTestCase): +class AccountTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.account = AccountFactory( name="Test Account", plan_seat_count=10, free_seat_count=1 diff --git a/graphql_api/tests/test_billing.py b/graphql_api/tests/test_billing.py index 71efb7979c..5a9602925a 100644 --- a/graphql_api/tests/test_billing.py +++ b/graphql_api/tests/test_billing.py @@ -1,13 +1,13 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import OwnerFactory from stripe.api_resources import PaymentIntent, SetupIntent from .helper import GraphQLTestHelper -class BillingTestCase(GraphQLTestHelper, TransactionTestCase): +class BillingTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(stripe_customer_id="test-customer-id") diff --git a/graphql_api/tests/test_branch.py b/graphql_api/tests/test_branch.py index bf160ea6f1..1e8f9405fa 100644 --- a/graphql_api/tests/test_branch.py +++ b/graphql_api/tests/test_branch.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta from unittest.mock import PropertyMock, patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import ( BranchFactory, CommitFactory, @@ -206,7 +206,7 @@ def get_flag_names(self): return [] -class TestBranch(GraphQLTestHelper, TransactionTestCase): +class TestBranch(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory(author=self.org, name="gazebo", private=False) diff --git a/graphql_api/tests/test_bundle_analysis_measurements.py b/graphql_api/tests/test_bundle_analysis_measurements.py index 25627f65a9..8e52c304d2 100644 --- a/graphql_api/tests/test_bundle_analysis_measurements.py +++ b/graphql_api/tests/test_bundle_analysis_measurements.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.api_archive.archive import ArchiveService from shared.bundle_analysis import StoragePaths from shared.bundle_analysis.storage import get_bucket_name @@ -18,7 +18,7 @@ from .helper import GraphQLTestHelper -class TestBundleAnalysisMeasurements(GraphQLTestHelper, TransactionTestCase): +class TestBundleAnalysisMeasurements(GraphQLTestHelper, TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/graphql_api/tests/test_commit.py b/graphql_api/tests/test_commit.py index 97a3deacf5..d1924add48 100644 --- a/graphql_api/tests/test_commit.py +++ b/graphql_api/tests/test_commit.py @@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, PropertyMock, patch import yaml -from django.test import TransactionTestCase +from django.test import TestCase from shared.api_archive.archive import ArchiveService from shared.bundle_analysis import StoragePaths from shared.bundle_analysis.storage import get_bucket_name @@ -106,7 +106,7 @@ def get(self, file, _else): return None -class TestCommit(GraphQLTestHelper, TransactionTestCase): +class TestCommit(GraphQLTestHelper, TestCase): def setUp(self): asyncio.set_event_loop(asyncio.new_event_loop()) self.org = OwnerFactory(username="codecov") diff --git a/graphql_api/tests/test_components.py b/graphql_api/tests/test_components.py index cd2521338c..50c4d777c7 100644 --- a/graphql_api/tests/test_components.py +++ b/graphql_api/tests/test_components.py @@ -2,7 +2,7 @@ import pytest from django.conf import settings -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from shared.django_apps.core.tests.factories import ( CommitFactory, @@ -138,7 +138,7 @@ def sample_report(): """ -class TestCommitCoverageComponents(GraphQLTestHelper, TransactionTestCase): +class TestCommitCoverageComponents(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) @@ -474,7 +474,7 @@ def test_components_filtering_case_insensitive( """ -class TestComponentsComparison(GraphQLTestHelper, TransactionTestCase): +class TestComponentsComparison(GraphQLTestHelper, TestCase): databases = {"default", "timeseries"} def setUp(self): @@ -906,7 +906,7 @@ def test_repository_components_metadata_backfilled_true(self, is_backfilled): @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class TestComponentMeasurements(GraphQLTestHelper, TransactionTestCase): +class TestComponentMeasurements(GraphQLTestHelper, TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/graphql_api/tests/test_coverage_analytics.py b/graphql_api/tests/test_coverage_analytics.py index 120f3526a7..bf31fb819e 100644 --- a/graphql_api/tests/test_coverage_analytics.py +++ b/graphql_api/tests/test_coverage_analytics.py @@ -1,7 +1,7 @@ import datetime from typing import Any, Dict, Optional -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from freezegun import freeze_time from shared.django_apps.core.tests.factories import ( @@ -20,7 +20,7 @@ from graphql_api.types.errors.errors import NotFoundError -class TestFetchCoverageAnalytics(GraphQLTestHelper, TransactionTestCase): +class TestFetchCoverageAnalytics(GraphQLTestHelper, TestCase): # SETUP def setUp(self) -> None: self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/tests/test_coverage_analytics_measurements.py b/graphql_api/tests/test_coverage_analytics_measurements.py index efd3eaaa05..dc7abc1a21 100644 --- a/graphql_api/tests/test_coverage_analytics_measurements.py +++ b/graphql_api/tests/test_coverage_analytics_measurements.py @@ -1,7 +1,7 @@ import datetime from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from shared.django_apps.core.tests.factories import ( OwnerFactory, @@ -14,7 +14,7 @@ @patch("timeseries.helpers.repository_coverage_measurements_with_fallback") -class TestMeasurement(TransactionTestCase, GraphQLTestHelper): +class TestMeasurement(TestCase, GraphQLTestHelper): def _request(self, variables=None): query = f""" query Measurements($branch: String) {{ diff --git a/graphql_api/tests/test_current_user_ariadne.py b/graphql_api/tests/test_current_user_ariadne.py index 50ab217ea2..d22aa9f3ba 100644 --- a/graphql_api/tests/test_current_user_ariadne.py +++ b/graphql_api/tests/test_current_user_ariadne.py @@ -2,7 +2,7 @@ from http.cookies import SimpleCookie from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( AccountFactory, OktaSettingsFactory, @@ -19,7 +19,7 @@ from .helper import GraphQLTestHelper, paginate_connection -class ArianeTestCase(GraphQLTestHelper, TransactionTestCase): +class ArianeTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") random_owner = OwnerFactory(username="random-user") diff --git a/graphql_api/tests/test_flags.py b/graphql_api/tests/test_flags.py index e42ca858e1..d8b21d85a2 100644 --- a/graphql_api/tests/test_flags.py +++ b/graphql_api/tests/test_flags.py @@ -2,7 +2,7 @@ import pytest from django.conf import settings -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from shared.django_apps.core.tests.factories import ( CommitFactory, @@ -98,7 +98,7 @@ @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class TestFlags(GraphQLTestHelper, TransactionTestCase): +class TestFlags(GraphQLTestHelper, TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/graphql_api/tests/test_impacted_file.py b/graphql_api/tests/test_impacted_file.py index 4ad6b8621c..f81ca5ac2f 100644 --- a/graphql_api/tests/test_impacted_file.py +++ b/graphql_api/tests/test_impacted_file.py @@ -3,7 +3,7 @@ from typing import Callable from unittest.mock import PropertyMock, patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -251,7 +251,7 @@ def sample_report(): return report -class TestImpactedFileFiltering(GraphQLTestHelper, TransactionTestCase): +class TestImpactedFileFiltering(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory(author=self.org, name="gazebo", private=False) @@ -357,7 +357,7 @@ def test_filtering_with_unknown_flags( ] == {"message": "No coverage with chosen flags"} -class TestImpactedFile(GraphQLTestHelper, TransactionTestCase): +class TestImpactedFile(GraphQLTestHelper, TestCase): def setUp(self): self.org = OwnerFactory(username="codecov") self.repo = RepositoryFactory(author=self.org, name="gazebo", private=False) diff --git a/graphql_api/tests/test_invoice.py b/graphql_api/tests/test_invoice.py index 3610239f24..f738c9f2c1 100644 --- a/graphql_api/tests/test_invoice.py +++ b/graphql_api/tests/test_invoice.py @@ -1,7 +1,7 @@ import json from unittest.mock import patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from utils.test_utils import Client @@ -9,7 +9,7 @@ from .helper import GraphQLTestHelper -class TestInvoiceType(GraphQLTestHelper, TransactionTestCase): +class TestInvoiceType(GraphQLTestHelper, TestCase): def setUp(self): self.service = "gitlab" self.current_owner = OwnerFactory(stripe_customer_id="1000") diff --git a/graphql_api/tests/test_okta_config.py b/graphql_api/tests/test_okta_config.py index 9e86556bbd..e8a6f59899 100644 --- a/graphql_api/tests/test_okta_config.py +++ b/graphql_api/tests/test_okta_config.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( AccountFactory, OktaSettingsFactory, @@ -8,7 +8,7 @@ from .helper import GraphQLTestHelper -class OktaConfigTestCase(GraphQLTestHelper, TransactionTestCase): +class OktaConfigTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.account = AccountFactory(name="Test Account") self.owner = OwnerFactory( diff --git a/graphql_api/tests/test_onboarding.py b/graphql_api/tests/test_onboarding.py index 0c0c4e2f24..c9f6c85360 100644 --- a/graphql_api/tests/test_onboarding.py +++ b/graphql_api/tests/test_onboarding.py @@ -1,10 +1,10 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from graphql_api.tests.helper import GraphQLTestHelper -class OnboardingTest(GraphQLTestHelper, TransactionTestCase): +class OnboardingTest(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.params = { diff --git a/graphql_api/tests/test_owner.py b/graphql_api/tests/test_owner.py index 80f1654fbc..f153dd0e09 100644 --- a/graphql_api/tests/test_owner.py +++ b/graphql_api/tests/test_owner.py @@ -2,7 +2,7 @@ from datetime import timedelta from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from django.utils import timezone from freezegun import freeze_time from graphql import GraphQLError @@ -57,7 +57,7 @@ """ -class TestOwnerType(GraphQLTestHelper, TransactionTestCase): +class TestOwnerType(GraphQLTestHelper, TestCase): def setUp(self): mock_all_plans_and_tiers() self.account = AccountFactory() diff --git a/graphql_api/tests/test_owner_measurements.py b/graphql_api/tests/test_owner_measurements.py index aae0fbe159..c5a67a094e 100644 --- a/graphql_api/tests/test_owner_measurements.py +++ b/graphql_api/tests/test_owner_measurements.py @@ -1,7 +1,7 @@ from datetime import datetime, timezone from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from timeseries.models import Interval @@ -10,7 +10,7 @@ @patch("timeseries.helpers.owner_coverage_measurements_with_fallback") -class TestOwnerMeasurements(TransactionTestCase, GraphQLTestHelper): +class TestOwnerMeasurements(TestCase, GraphQLTestHelper): def _request(self, variables=None): query = f""" query Measurements($repos: [String!]) {{ diff --git a/graphql_api/tests/test_path_content.py b/graphql_api/tests/test_path_content.py index 95c90056d7..71499934bf 100644 --- a/graphql_api/tests/test_path_content.py +++ b/graphql_api/tests/test_path_content.py @@ -1,6 +1,6 @@ from unittest.mock import Mock, PropertyMock, patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import CommitFactory from shared.reports.resources import Report, ReportFile from shared.reports.types import ReportLine, ReportTotals @@ -55,7 +55,7 @@ def test_returns_none(self): assert type is None -class TestPathContents(TransactionTestCase): +class TestPathContents(TestCase): def setUp(self): request = Mock() request.user = Mock() diff --git a/graphql_api/tests/test_plan.py b/graphql_api/tests/test_plan.py index cac22a7914..2e73e5de4b 100644 --- a/graphql_api/tests/test_plan.py +++ b/graphql_api/tests/test_plan.py @@ -2,7 +2,7 @@ from unittest.mock import patch import pytest -from django.test import TransactionTestCase +from django.test import TestCase from django.utils import timezone from freezegun import freeze_time from shared.django_apps.codecov_auth.tests.factories import AccountFactory @@ -16,7 +16,7 @@ from .helper import GraphQLTestHelper -class TestPlanType(GraphQLTestHelper, TransactionTestCase): +class TestPlanType(GraphQLTestHelper, TestCase): @pytest.fixture(scope="function", autouse=True) def inject_mocker(request, mocker): request.mocker = mocker diff --git a/graphql_api/tests/test_plan_representation.py b/graphql_api/tests/test_plan_representation.py index bd562bde3e..3f8b5d5958 100644 --- a/graphql_api/tests/test_plan_representation.py +++ b/graphql_api/tests/test_plan_representation.py @@ -1,6 +1,6 @@ from datetime import timedelta -from django.test import TransactionTestCase +from django.test import TestCase from django.utils import timezone from freezegun import freeze_time from shared.django_apps.core.tests.factories import OwnerFactory @@ -11,7 +11,7 @@ from .helper import GraphQLTestHelper -class TestPlanRepresentationsType(GraphQLTestHelper, TransactionTestCase): +class TestPlanRepresentationsType(GraphQLTestHelper, TestCase): def setUp(self): mock_all_plans_and_tiers() self.current_org = OwnerFactory( diff --git a/graphql_api/tests/test_pull.py b/graphql_api/tests/test_pull.py index 4e2ca533df..efa8c27391 100644 --- a/graphql_api/tests/test_pull.py +++ b/graphql_api/tests/test_pull.py @@ -3,7 +3,7 @@ from unittest.mock import patch import pytest -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from shared.api_archive.archive import ArchiveService from shared.bundle_analysis import StoragePaths @@ -144,7 +144,7 @@ """ -class TestPullRequestList(GraphQLTestHelper, TransactionTestCase): +class TestPullRequestList(GraphQLTestHelper, TestCase): def fetch_list_pull_request(self): data = self.gql_request(query_list_pull_request, owner=self.owner) return paginate_connection(data["me"]["owner"]["repository"]["pulls"]) diff --git a/graphql_api/tests/test_pull_comparison.py b/graphql_api/tests/test_pull_comparison.py index ccf278097e..93421d7c48 100644 --- a/graphql_api/tests/test_pull_comparison.py +++ b/graphql_api/tests/test_pull_comparison.py @@ -1,7 +1,7 @@ from collections import namedtuple from unittest.mock import PropertyMock, patch -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitWithReportFactory, OwnerFactory, @@ -41,7 +41,7 @@ ) -class TestPullComparison(TransactionTestCase, GraphQLTestHelper): +class TestPullComparison(TestCase, GraphQLTestHelper): def _request(self, query): data = self.gql_request( base_query % (self.repository.name, self.pull.pullid, query), diff --git a/graphql_api/tests/test_repository.py b/graphql_api/tests/test_repository.py index 4f6653c9fb..5eb3d17afb 100644 --- a/graphql_api/tests/test_repository.py +++ b/graphql_api/tests/test_repository.py @@ -1,7 +1,7 @@ import datetime from unittest.mock import patch -from django.test import TransactionTestCase, override_settings +from django.test import TestCase, override_settings from freezegun import freeze_time from shared.django_apps.core.tests.factories import ( CommitFactory, @@ -77,7 +77,7 @@ def mock_get_config_global_upload_tokens(*args): return True -class TestFetchRepository(GraphQLTestHelper, TransactionTestCase): +class TestFetchRepository(GraphQLTestHelper, TestCase): def fetch_repository(self, name, fields=None): data = self.gql_request( query_repository % (fields or default_fields), diff --git a/graphql_api/tests/test_session.py b/graphql_api/tests/test_session.py index 868fd3fcd1..c0d3fc15f4 100644 --- a/graphql_api/tests/test_session.py +++ b/graphql_api/tests/test_session.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from shared.django_apps.codecov_auth.tests.factories import OwnerFactory, SessionFactory @@ -24,7 +24,7 @@ """ -class SessionTestCase(GraphQLTestHelper, TransactionTestCase): +class SessionTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") self.session = SessionFactory( diff --git a/graphql_api/tests/test_user.py b/graphql_api/tests/test_user.py index ef067c84fc..aad72fc92a 100644 --- a/graphql_api/tests/test_user.py +++ b/graphql_api/tests/test_user.py @@ -1,6 +1,6 @@ from datetime import timedelta -from django.test import TransactionTestCase +from django.test import TestCase from django.utils import timezone from freezegun import freeze_time from prometheus_client import REGISTRY @@ -13,7 +13,7 @@ @freeze_time("2023-06-19") -class UserTestCase(GraphQLTestHelper, TransactionTestCase): +class UserTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.service_id = 1 self.user = OwnerFactory( diff --git a/graphql_api/tests/test_user_tokens.py b/graphql_api/tests/test_user_tokens.py index e09ac6c44b..ee475d1ef7 100644 --- a/graphql_api/tests/test_user_tokens.py +++ b/graphql_api/tests/test_user_tokens.py @@ -1,4 +1,4 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.codecov_auth.tests.factories import ( OwnerFactory, UserTokenFactory, @@ -25,7 +25,7 @@ """ -class UserTokensTestCase(GraphQLTestHelper, TransactionTestCase): +class UserTokensTestCase(GraphQLTestHelper, TestCase): def setUp(self): self.owner = OwnerFactory(username="codecov-user") diff --git a/graphql_api/types/account/account.py b/graphql_api/types/account/account.py index 8076961cc9..8bcfc17225 100644 --- a/graphql_api/types/account/account.py +++ b/graphql_api/types/account/account.py @@ -1,9 +1,9 @@ from typing import Any, Coroutine, Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql import GraphQLResolveInfo -from codecov.db import sync_to_async from codecov_auth.models import Account, OktaSettings, Owner from graphql_api.helpers.ariadne import ariadne_load_local_graphql from graphql_api.helpers.connection import ( diff --git a/graphql_api/types/bundle_analysis/base.py b/graphql_api/types/bundle_analysis/base.py index 1620fde3ac..a63c41f269 100644 --- a/graphql_api/types/bundle_analysis/base.py +++ b/graphql_api/types/bundle_analysis/base.py @@ -4,10 +4,10 @@ import sentry_sdk from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql import GraphQLResolveInfo from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from graphql_api.types.enums import AssetOrdering, OrderingDirection from services.bundle_analysis import ( AssetReport, diff --git a/graphql_api/types/commit/commit.py b/graphql_api/types/commit/commit.py index 076f3019d7..560b496fa4 100644 --- a/graphql_api/types/commit/commit.py +++ b/graphql_api/types/commit/commit.py @@ -5,6 +5,7 @@ import shared.reports.api_report_service as report_service import yaml from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql import GraphQLResolveInfo from shared.reports.api_report_service import ReadOnlyReport from shared.reports.filtered import FilteredReportFile @@ -13,7 +14,6 @@ import services.components as components_service import services.path as path_service -from codecov.db import sync_to_async from codecov_auth.models import Owner from core.models import Commit from graphql_api.actions.commits import commit_status, commit_uploads diff --git a/graphql_api/types/comparison/comparison.py b/graphql_api/types/comparison/comparison.py index fd3fc92b0e..3a6a0f2d2f 100644 --- a/graphql_api/types/comparison/comparison.py +++ b/graphql_api/types/comparison/comparison.py @@ -3,10 +3,10 @@ import sentry_sdk from ariadne import ObjectType, UnionType +from asgiref.sync import sync_to_async from graphql.type.definition import GraphQLResolveInfo import services.components as components_service -from codecov.db import sync_to_async from compare.commands.compare.compare import CompareCommands from compare.models import ComponentComparison, FlagComparison from graphql_api.actions.flags import get_flag_comparisons diff --git a/graphql_api/types/component/component.py b/graphql_api/types/component/component.py index 9a89c7c247..862751d68b 100644 --- a/graphql_api/types/component/component.py +++ b/graphql_api/types/component/component.py @@ -1,9 +1,9 @@ from typing import Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from shared.reports.types import ReportTotals -from codecov.db import sync_to_async from core.models import Commit from services.components import Component, component_filtered_report diff --git a/graphql_api/types/component_comparison/component_comparison.py b/graphql_api/types/component_comparison/component_comparison.py index f9dcef5497..5271bda950 100644 --- a/graphql_api/types/component_comparison/component_comparison.py +++ b/graphql_api/types/component_comparison/component_comparison.py @@ -1,7 +1,7 @@ from ariadne import ObjectType +from asgiref.sync import sync_to_async from shared.reports.types import ReportTotals -from codecov.db import sync_to_async from compare.models import ComponentComparison from services.components import Component diff --git a/graphql_api/types/config/config.py b/graphql_api/types/config/config.py index 87c57ef627..20bb2f3f14 100644 --- a/graphql_api/types/config/config.py +++ b/graphql_api/types/config/config.py @@ -1,12 +1,12 @@ from typing import List, Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from distutils.util import strtobool from django.conf import settings from graphql.type.definition import GraphQLResolveInfo import services.self_hosted as self_hosted -from codecov.db import sync_to_async from graphql_api.types.enums.enums import LoginProvider, SyncProvider config_bindable = ObjectType("Config") diff --git a/graphql_api/types/coverage_analytics/coverage_analytics.py b/graphql_api/types/coverage_analytics/coverage_analytics.py index f148af0aa2..556554f1e6 100644 --- a/graphql_api/types/coverage_analytics/coverage_analytics.py +++ b/graphql_api/types/coverage_analytics/coverage_analytics.py @@ -5,13 +5,13 @@ import sentry_sdk from ariadne import ObjectType, UnionType +from asgiref.sync import sync_to_async from django.conf import settings from django.forms.utils import from_current_timezone from graphql.type.definition import GraphQLResolveInfo from shared.yaml import UserYaml import timeseries.helpers as timeseries_helpers -from codecov.db import sync_to_async from core.models import Repository from graphql_api.actions.components import ( component_measurements, diff --git a/graphql_api/types/impacted_file/impacted_file.py b/graphql_api/types/impacted_file/impacted_file.py index 3cc3539e05..3847e26fb4 100644 --- a/graphql_api/types/impacted_file/impacted_file.py +++ b/graphql_api/types/impacted_file/impacted_file.py @@ -3,10 +3,10 @@ import sentry_sdk from ariadne import ObjectType, UnionType +from asgiref.sync import sync_to_async from shared.reports.types import ReportTotals from shared.torngit.exceptions import TorngitClientError -from codecov.db import sync_to_async from graphql_api.types.errors import ProviderError, UnknownPath from graphql_api.types.errors.errors import UnknownFlags from graphql_api.types.segment_comparison.segment_comparison import SegmentComparisons diff --git a/graphql_api/types/me/me.py b/graphql_api/types/me/me.py index aa41bbd4e6..a98f02abe6 100644 --- a/graphql_api/types/me/me.py +++ b/graphql_api/types/me/me.py @@ -1,9 +1,9 @@ from typing import Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql import GraphQLResolveInfo -from codecov.db import sync_to_async from codecov_auth.models import Owner, OwnerProfile from codecov_auth.views.okta_cloud import OKTA_SIGNED_IN_ACCOUNTS_SESSION_KEY from graphql_api.actions.owner import ( diff --git a/graphql_api/types/mutation/delete_component_measurements/delete_component_measurements.py b/graphql_api/types/mutation/delete_component_measurements/delete_component_measurements.py index 2f1e2b47c6..44aa4cfd3e 100644 --- a/graphql_api/types/mutation/delete_component_measurements/delete_component_measurements.py +++ b/graphql_api/types/mutation/delete_component_measurements/delete_component_measurements.py @@ -1,6 +1,6 @@ from ariadne import UnionType +from asgiref.sync import sync_to_async -from codecov.db import sync_to_async from core.commands.component import ComponentCommands from graphql_api.helpers.mutation import ( resolve_union_error_type, diff --git a/graphql_api/types/mutation/delete_flag/delete_flag.py b/graphql_api/types/mutation/delete_flag/delete_flag.py index ac530c4bdf..ed8b72a2b8 100644 --- a/graphql_api/types/mutation/delete_flag/delete_flag.py +++ b/graphql_api/types/mutation/delete_flag/delete_flag.py @@ -1,6 +1,6 @@ from ariadne import UnionType +from asgiref.sync import sync_to_async -from codecov.db import sync_to_async from core.commands.flag import FlagCommands from graphql_api.helpers.mutation import ( resolve_union_error_type, diff --git a/graphql_api/types/mutation/save_sentry_state/save_sentry_state.py b/graphql_api/types/mutation/save_sentry_state/save_sentry_state.py index c8481bce83..8db5749479 100644 --- a/graphql_api/types/mutation/save_sentry_state/save_sentry_state.py +++ b/graphql_api/types/mutation/save_sentry_state/save_sentry_state.py @@ -1,8 +1,8 @@ from ariadne import UnionType +from asgiref.sync import sync_to_async import services.sentry as sentry from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from graphql_api.helpers.mutation import ( require_authenticated, resolve_union_error_type, diff --git a/graphql_api/types/owner/owner.py b/graphql_api/types/owner/owner.py index 3203e30cdd..7876797f1d 100644 --- a/graphql_api/types/owner/owner.py +++ b/graphql_api/types/owner/owner.py @@ -6,6 +6,7 @@ import stripe import yaml from ariadne import ObjectType +from asgiref.sync import sync_to_async from django.conf import settings from graphql import GraphQLResolveInfo from shared.plan.constants import DEFAULT_FREE_PLAN @@ -13,7 +14,6 @@ import services.activation as activation import timeseries.helpers as timeseries_helpers -from codecov.db import sync_to_async from codecov_auth.constants import OWNER_YAML_TO_STRING_KEY from codecov_auth.helpers import current_user_part_of_org from codecov_auth.models import ( diff --git a/graphql_api/types/plan/plan.py b/graphql_api/types/plan/plan.py index a678fa03d7..c790170b77 100644 --- a/graphql_api/types/plan/plan.py +++ b/graphql_api/types/plan/plan.py @@ -2,10 +2,10 @@ from typing import List, Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from shared.plan.constants import PlanBillingRate, TrialStatus from shared.plan.service import PlanService -from codecov.db import sync_to_async from graphql_api.helpers.ariadne import ariadne_load_local_graphql plan = ariadne_load_local_graphql(__file__, "plan.graphql") diff --git a/graphql_api/types/plan_representation/plan_representation.py b/graphql_api/types/plan_representation/plan_representation.py index 910fe9bf9c..8ecc2f6434 100644 --- a/graphql_api/types/plan_representation/plan_representation.py +++ b/graphql_api/types/plan_representation/plan_representation.py @@ -1,9 +1,9 @@ from typing import List, Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from shared.plan.service import PlanService -from codecov.db import sync_to_async from codecov_auth.models import Plan from graphql_api.helpers.ariadne import ariadne_load_local_graphql diff --git a/graphql_api/types/pull/pull.py b/graphql_api/types/pull/pull.py index 4f1f4c98f7..1bcc74abd5 100644 --- a/graphql_api/types/pull/pull.py +++ b/graphql_api/types/pull/pull.py @@ -2,9 +2,9 @@ import sentry_sdk from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql import GraphQLResolveInfo -from codecov.db import sync_to_async from codecov_auth.models import Owner from compare.models import CommitComparison from core.models import Commit, Pull diff --git a/graphql_api/types/query/query.py b/graphql_api/types/query/query.py index 30bde8a686..9114aa8ef4 100644 --- a/graphql_api/types/query/query.py +++ b/graphql_api/types/query/query.py @@ -1,12 +1,12 @@ from typing import Any, Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from django.conf import settings from graphql import GraphQLResolveInfo from sentry_sdk import Scope from codecov.commands.exceptions import UnauthorizedGuestAccess -from codecov.db import sync_to_async from codecov_auth.models import Owner from graphql_api.actions.owner import get_owner from graphql_api.helpers.ariadne import ariadne_load_local_graphql diff --git a/graphql_api/types/repository/repository.py b/graphql_api/types/repository/repository.py index cf286c7d1f..a220d0c638 100644 --- a/graphql_api/types/repository/repository.py +++ b/graphql_api/types/repository/repository.py @@ -5,10 +5,10 @@ import shared.rate_limits as rate_limits import yaml from ariadne import ObjectType, UnionType +from asgiref.sync import sync_to_async from django.conf import settings from graphql.type.definition import GraphQLResolveInfo -from codecov.db import sync_to_async from codecov_auth.models import SERVICE_GITHUB, SERVICE_GITHUB_ENTERPRISE, Owner from core.models import Branch, Commit, Pull, Repository from graphql_api.actions.commits import repo_commits diff --git a/graphql_api/types/repository_config/repository_config.py b/graphql_api/types/repository_config/repository_config.py index 46f06d2340..289ff315ca 100644 --- a/graphql_api/types/repository_config/repository_config.py +++ b/graphql_api/types/repository_config/repository_config.py @@ -1,9 +1,9 @@ from typing import TypedDict from ariadne import ObjectType +from asgiref.sync import sync_to_async from shared.yaml.user_yaml import UserYaml -from codecov.db import sync_to_async from core.models import Repository from graphql_api.dataloader.owner import OwnerLoader diff --git a/graphql_api/types/test_analytics/test_analytics.py b/graphql_api/types/test_analytics/test_analytics.py index ed70412d15..df1f22acca 100644 --- a/graphql_api/types/test_analytics/test_analytics.py +++ b/graphql_api/types/test_analytics/test_analytics.py @@ -6,11 +6,11 @@ import polars as pl from ariadne import ObjectType +from asgiref.sync import sync_to_async from graphql.type.definition import GraphQLResolveInfo from shared.django_apps.core.models import Repository from codecov.commands.exceptions import ValidationError -from codecov.db import sync_to_async from graphql_api.types.enums import ( OrderingDirection, TestResultsFilterParameter, diff --git a/graphql_api/types/upload/upload.py b/graphql_api/types/upload/upload.py index 1a8997ffc0..291a41cea4 100644 --- a/graphql_api/types/upload/upload.py +++ b/graphql_api/types/upload/upload.py @@ -1,10 +1,10 @@ from typing import Optional from ariadne import ObjectType +from asgiref.sync import sync_to_async from django.urls import reverse from shared.django_apps.utils.services import get_short_service_name -from codecov.db import sync_to_async from graphql_api.helpers.connection import queryset_to_connection from graphql_api.types.enums import ( OrderingDirection, diff --git a/graphql_api/views.py b/graphql_api/views.py index 4d9eb9da16..0cb7b97f5b 100644 --- a/graphql_api/views.py +++ b/graphql_api/views.py @@ -11,6 +11,7 @@ from ariadne.types import Extension from ariadne.validation import cost_validator from ariadne_django.views import GraphQLAsyncView +from asgiref.sync import sync_to_async from django.conf import settings from django.core.handlers.wsgi import WSGIRequest from django.http import ( @@ -25,7 +26,6 @@ from codecov.commands.exceptions import BaseException from codecov.commands.executor import get_executor_from_request -from codecov.db import sync_to_async from services import ServiceException from services.redis_configuration import get_redis_connection diff --git a/legacy_migrations/tests/unit/test_models.py b/legacy_migrations/tests/unit/test_models.py index 64af218333..45db86639d 100644 --- a/legacy_migrations/tests/unit/test_models.py +++ b/legacy_migrations/tests/unit/test_models.py @@ -1,11 +1,11 @@ -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory from legacy_migrations.models import YamlHistory from legacy_migrations.tests.factories import YamlHistoryFactory -class TestYamlHistory(TransactionTestCase): +class TestYamlHistory(TestCase): def test_get_pieces_of_model(self): owner = OwnerFactory() author = OwnerFactory() diff --git a/services/bundle_analysis.py b/services/bundle_analysis.py index d1920bba1c..387e27a9e1 100644 --- a/services/bundle_analysis.py +++ b/services/bundle_analysis.py @@ -6,6 +6,7 @@ from typing import Any, Dict, Iterable, List, Optional, Union import sentry_sdk +from asgiref.sync import sync_to_async from django.utils.functional import cached_property from shared.api_archive.archive import ArchiveService from shared.bundle_analysis import AssetReport as SharedAssetReport @@ -23,7 +24,6 @@ ) from shared.storage import get_appropriate_storage_service -from codecov.db import sync_to_async from core.models import Commit, Repository from graphql_api.actions.measurements import ( measurements_by_ids, diff --git a/services/repo_providers.py b/services/repo_providers.py index 09a18ac574..da25e7cf33 100644 --- a/services/repo_providers.py +++ b/services/repo_providers.py @@ -2,11 +2,11 @@ from os import getenv from typing import Callable, Dict, Optional +from asgiref.sync import sync_to_async from django.conf import settings from shared.encryption.token import encode_token from shared.torngit import get -from codecov.db import sync_to_async from codecov_auth.models import ( GITHUB_APP_INSTALLATION_DEFAULT_NAME, GithubAppInstallation, diff --git a/services/tests/test_components.py b/services/tests/test_components.py index e43001afce..0daf54caab 100644 --- a/services/tests/test_components.py +++ b/services/tests/test_components.py @@ -1,7 +1,7 @@ from unittest.mock import PropertyMock, patch from django.contrib.auth.models import AnonymousUser -from django.test import TransactionTestCase +from django.test import TestCase from shared.components import Component from shared.django_apps.core.tests.factories import ( CommitFactory, @@ -46,7 +46,7 @@ def sample_report(): return report -class ComponentServiceTest(TransactionTestCase): +class ComponentServiceTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) @@ -138,7 +138,7 @@ def test_component_filtered_report(self): assert report_py.totals.coverage == report.get("file_2.py").totals.coverage -class ComponentComparisonTest(TransactionTestCase): +class ComponentComparisonTest(TestCase): def setUp(self): self.user = OwnerFactory() self.repo = RepositoryFactory(author=self.user) diff --git a/services/tests/test_repo_providers.py b/services/tests/test_repo_providers.py index f515fde88e..5e301abb2f 100644 --- a/services/tests/test_repo_providers.py +++ b/services/tests/test_repo_providers.py @@ -2,12 +2,12 @@ from unittest.mock import patch import pytest +from asgiref.sync import sync_to_async from django.conf import settings -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory from shared.torngit import Bitbucket, Github, Gitlab -from codecov.db import sync_to_async from codecov_auth.models import ( GITHUB_APP_INSTALLATION_DEFAULT_NAME, GithubAppInstallation, @@ -114,7 +114,7 @@ def test_token_refresh_callback_none_cases(should_have_owner, service, db): assert get_token_refresh_callback(owner, service) is None -class TestRepoProviderService(TransactionTestCase): +class TestRepoProviderService(TestCase): def setUp(self): self.repo_gh = RepositoryFactory.create( author__unencrypted_oauth_token="testaaft3ituvli790m1yajovjv5eg0r4j0264iw", diff --git a/services/tests/test_yaml.py b/services/tests/test_yaml.py index 7b5237fe37..4bdf184cd5 100644 --- a/services/tests/test_yaml.py +++ b/services/tests/test_yaml.py @@ -1,7 +1,7 @@ from unittest.mock import patch import pytest -from django.test import TransactionTestCase +from django.test import TestCase from shared.django_apps.core.tests.factories import ( CommitFactory, OwnerFactory, @@ -12,7 +12,7 @@ import services.yaml as yaml -class YamlServiceTest(TransactionTestCase): +class YamlServiceTest(TestCase): def setUp(self): self.org = OwnerFactory() self.repo = RepositoryFactory(author=self.org, private=False) diff --git a/timeseries/tests/test_admin.py b/timeseries/tests/test_admin.py index 0387fe4985..6f3c15eb16 100644 --- a/timeseries/tests/test_admin.py +++ b/timeseries/tests/test_admin.py @@ -3,7 +3,7 @@ import pytest from django.conf import settings from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME -from django.test import TransactionTestCase +from django.test import TestCase from django.urls import reverse from django.utils import timezone from shared.django_apps.codecov_auth.tests.factories import UserFactory @@ -14,7 +14,7 @@ @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class DatasetAdminTest(TransactionTestCase): +class DatasetAdminTest(TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/timeseries/tests/test_helpers.py b/timeseries/tests/test_helpers.py index 702400a5a6..b51540e970 100644 --- a/timeseries/tests/test_helpers.py +++ b/timeseries/tests/test_helpers.py @@ -3,7 +3,7 @@ import pytest from django.conf import settings -from django.test import TransactionTestCase +from django.test import TestCase from freezegun import freeze_time from freezegun.api import FakeDatetime from shared.django_apps.core.tests.factories import ( @@ -56,7 +56,7 @@ def sample_report(): @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class RefreshMeasurementSummariesTest(TransactionTestCase): +class RefreshMeasurementSummariesTest(TestCase): databases = {"timeseries"} @patch("django.db.backends.utils.CursorWrapper.execute") @@ -78,7 +78,7 @@ def test_refresh_measurement_summaries(self, execute): @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class RepositoryCoverageMeasurementsTest(TransactionTestCase): +class RepositoryCoverageMeasurementsTest(TestCase): databases = {"default", "timeseries"} def setUp(self): @@ -155,7 +155,7 @@ def test_coverage_measurements(self): @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class FillSparseMeasurementsTest(TransactionTestCase): +class FillSparseMeasurementsTest(TestCase): databases = {"default", "timeseries"} def setUp(self): @@ -390,7 +390,7 @@ def test_fill_sparse_measurements_no_measurements(self): @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class RepositoryCoverageMeasurementsWithFallbackTest(TransactionTestCase): +class RepositoryCoverageMeasurementsWithFallbackTest(TestCase): databases = {"default", "timeseries"} def setUp(self): @@ -804,7 +804,7 @@ def test_backfill_not_triggered_if_no_dataset_creation( @pytest.mark.skipif( not settings.TIMESERIES_ENABLED, reason="requires timeseries data storage" ) -class OwnerCoverageMeasurementsWithFallbackTest(TransactionTestCase): +class OwnerCoverageMeasurementsWithFallbackTest(TestCase): databases = {"default", "timeseries"} def setUp(self): diff --git a/upload/tests/test_upload_download.py b/upload/tests/test_upload_download.py index b255f84608..89c7d6fba3 100644 --- a/upload/tests/test_upload_download.py +++ b/upload/tests/test_upload_download.py @@ -2,13 +2,13 @@ import minio from ddf import G -from rest_framework.test import APITransactionTestCase +from rest_framework.test import APITestCase from codecov_auth.models import Owner from core.models import Repository -class UploadDownloadHelperTest(APITransactionTestCase): +class UploadDownloadHelperTest(APITestCase): def _get(self, kwargs={}, data={}): path = f"/upload/{kwargs.get('service')}/{kwargs.get('owner_username')}/{kwargs.get('repo_name')}/download" return self.client.get(path, data=data) diff --git a/upload/views/legacy.py b/upload/views/legacy.py index ce56a6fc4f..4eaf50cdf9 100644 --- a/upload/views/legacy.py +++ b/upload/views/legacy.py @@ -5,6 +5,7 @@ from uuid import uuid4 import minio +from asgiref.sync import sync_to_async from django.conf import settings from django.core.exceptions import MultipleObjectsReturned from django.http import Http404, HttpResponse, HttpResponseServerError @@ -19,7 +20,6 @@ from shared.api_archive.archive import ArchiveService from shared.metrics import inc_counter -from codecov.db import sync_to_async from codecov_auth.commands.owner import OwnerCommands from core.commands.repository import RepositoryCommands from services.analytics import AnalyticsService