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

Commit 786d94a

Browse files
authored
Replace usage of TransactionTestCase (#1183)
1 parent a74ce80 commit 786d94a

File tree

189 files changed

+344
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+344
-335
lines changed

codecov/db/__init__.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import logging
22

3-
from asgiref.sync import SyncToAsync
43
from django.conf import settings
5-
from django.db import close_old_connections
64
from django.db.models import Field, Lookup
75

86
log = logging.getLogger(__name__)
@@ -69,19 +67,3 @@ def as_sql(self, compiler, connection):
6967
rhs, rhs_params = self.process_rhs(compiler, connection)
7068
params = tuple(lhs_params) + tuple(rhs_params)
7169
return "%s is not %s" % (lhs, rhs), params
72-
73-
74-
class DatabaseSyncToAsync(SyncToAsync):
75-
"""
76-
SyncToAsync version that cleans up old database connections.
77-
"""
78-
79-
def thread_handler(self, loop, *args, **kwargs):
80-
close_old_connections()
81-
try:
82-
return super().thread_handler(loop, *args, **kwargs)
83-
finally:
84-
close_old_connections()
85-
86-
87-
sync_to_async = DatabaseSyncToAsync

codecov_auth/commands/owner/interactors/cancel_trial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from asgiref.sync import sync_to_async
12
from shared.plan.service import PlanService
23

34
from codecov.commands.base import BaseInteractor
45
from codecov.commands.exceptions import Unauthorized, ValidationError
5-
from codecov.db import sync_to_async
66
from codecov_auth.helpers import current_user_part_of_org
77
from codecov_auth.models import Owner
88

codecov_auth/commands/owner/interactors/create_api_token.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from asgiref.sync import sync_to_async
2+
13
from codecov.commands.base import BaseInteractor
24
from codecov.commands.exceptions import Unauthenticated, ValidationError
3-
from codecov.db import sync_to_async
45
from codecov_auth.models import Session
56

67

codecov_auth/commands/owner/interactors/create_stripe_setup_intent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging
22

33
import stripe
4+
from asgiref.sync import sync_to_async
45

56
from codecov.commands.base import BaseInteractor
67
from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError
7-
from codecov.db import sync_to_async
88
from codecov_auth.helpers import current_user_part_of_org
99
from codecov_auth.models import Owner
1010
from services.billing import BillingService

codecov_auth/commands/owner/interactors/create_user_token.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from asgiref.sync import sync_to_async
2+
13
from codecov.commands.base import BaseInteractor
24
from codecov.commands.exceptions import Unauthenticated, ValidationError
3-
from codecov.db import sync_to_async
45
from codecov_auth.models import UserToken
56

67

codecov_auth/commands/owner/interactors/delete_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from asgiref.sync import sync_to_async
12
from django.contrib.sessions.models import Session as DjangoSession
23

34
from codecov.commands.base import BaseInteractor
45
from codecov.commands.exceptions import Unauthenticated
5-
from codecov.db import sync_to_async
66
from codecov_auth.models import Session
77

88

codecov_auth/commands/owner/interactors/fetch_owner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from asgiref.sync import sync_to_async
2+
13
from codecov.commands.base import BaseInteractor
2-
from codecov.db import sync_to_async
34
from codecov_auth.models import Owner
45

56

codecov_auth/commands/owner/interactors/get_org_upload_token.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from asgiref.sync import sync_to_async
2+
13
from codecov.commands.base import BaseInteractor
24
from codecov.commands.exceptions import Unauthenticated, Unauthorized
3-
from codecov.db import sync_to_async
45
from codecov_auth.helpers import current_user_part_of_org
56
from codecov_auth.models import OrganizationLevelToken
67

codecov_auth/commands/owner/interactors/get_uploads_number_per_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from typing import Optional
22

3+
from asgiref.sync import sync_to_async
34
from shared.plan.service import PlanService
45
from shared.upload.utils import query_monthly_coverage_measurements
56

67
from codecov.commands.base import BaseInteractor
7-
from codecov.db import sync_to_async
88
from codecov_auth.models import Owner
99
from services.redis_configuration import get_redis_connection
1010

codecov_auth/commands/owner/interactors/is_syncing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from asgiref.sync import sync_to_async
2+
13
from codecov.commands.base import BaseInteractor
2-
from codecov.db import sync_to_async
34
from services.refresh import RefreshService
45

56

0 commit comments

Comments
 (0)