From 3777e060af2506107344f67fa081fa2c758f1e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Wed, 18 Dec 2024 14:59:33 +0100 Subject: [PATCH 1/4] server: chase unnecessary calls to `session.commit()` This can hurt the idempotency of our tasks and consistency in DB. --- server/polar/account/service.py | 3 --- server/polar/benefit/service/benefit_grant.py | 4 ++-- server/polar/integrations/github/service/user.py | 2 +- server/polar/integrations/stripe/service.py | 4 ++-- server/polar/kit/services.py | 2 +- server/polar/magic_link/service.py | 2 -- server/polar/notifications/service.py | 5 ++--- server/polar/user/service/user.py | 1 - server/polar/user_organization/service.py | 1 - 9 files changed, 8 insertions(+), 16 deletions(-) diff --git a/server/polar/account/service.py b/server/polar/account/service.py index a9e73de2a8..678a38ef12 100644 --- a/server/polar/account/service.py +++ b/server/polar/account/service.py @@ -133,7 +133,6 @@ async def check_review_threshold( ): account.status = Account.Status.UNDER_REVIEW session.add(account) - await session.commit() enqueue_job("account.under_review", account_id=account.id) @@ -156,7 +155,6 @@ async def confirm_account_reviewed( account.next_review_threshold = None session.add(account) - await session.commit() enqueue_job("account.reviewed", account_id=account.id) @@ -286,7 +284,6 @@ async def update_account_from_stripe( account.status = Account.Status.ONBOARDING_STARTED session.add(account) - await session.commit() return account diff --git a/server/polar/benefit/service/benefit_grant.py b/server/polar/benefit/service/benefit_grant.py index 8b98f007df..b68f6fb4f4 100644 --- a/server/polar/benefit/service/benefit_grant.py +++ b/server/polar/benefit/service/benefit_grant.py @@ -160,7 +160,7 @@ async def grant_benefit( grant.set_granted() session.add(grant) - await session.commit() + await session.flush() await eventstream_publish( "benefit.granted", @@ -230,7 +230,7 @@ async def revoke_benefit( grant.set_revoked() session.add(grant) - await session.commit() + await session.flush() await eventstream_publish( "benefit.revoked", diff --git a/server/polar/integrations/github/service/user.py b/server/polar/integrations/github/service/user.py index a8db76ac1a..e6f9a27abe 100644 --- a/server/polar/integrations/github/service/user.py +++ b/server/polar/integrations/github/service/user.py @@ -139,7 +139,7 @@ async def create( ) session.add(new_user) - await session.commit() + await session.flush() log.info("github.user.create", user_id=new_user.id, username=github_user.login) diff --git a/server/polar/integrations/stripe/service.py b/server/polar/integrations/stripe/service.py index f177a49aba..feaf473808 100644 --- a/server/polar/integrations/stripe/service.py +++ b/server/polar/integrations/stripe/service.py @@ -247,7 +247,7 @@ async def get_or_create_user_customer( .values(stripe_customer_id=customer.id) ) await session.execute(stmt) - await session.commit() + await session.flush() return customer @@ -278,7 +278,7 @@ async def get_or_create_org_customer( .values(stripe_customer_id=customer.id) ) await session.execute(stmt) - await session.commit() + await session.flush() return customer diff --git a/server/polar/kit/services.py b/server/polar/kit/services.py index 18c5ed5070..c9d82a8464 100644 --- a/server/polar/kit/services.py +++ b/server/polar/kit/services.py @@ -55,7 +55,7 @@ async def soft_delete(self, session: AsyncSession, id: UUID) -> None: ) ) await session.execute(stmt) - await session.commit() + await session.flush() class ResourceService( diff --git a/server/polar/magic_link/service.py b/server/polar/magic_link/service.py index 99bb7a1eb3..15f3cbb9c9 100644 --- a/server/polar/magic_link/service.py +++ b/server/polar/magic_link/service.py @@ -56,7 +56,6 @@ async def request( magic_link = MagicLink(**magic_link_create.model_dump(exclude_unset=True)) session.add(magic_link) - await session.commit() return magic_link, token @@ -127,7 +126,6 @@ async def authenticate( async def delete_expired(self, session: AsyncSession) -> None: statement = delete(MagicLink).where(MagicLink.expires_at < utc_now()) await session.execute(statement) - await session.commit() async def _get_valid_magic_link_by_token_hash( self, session: AsyncSession, token_hash: str diff --git a/server/polar/notifications/service.py b/server/polar/notifications/service.py index 6c6e775642..0dba50c1ae 100644 --- a/server/polar/notifications/service.py +++ b/server/polar/notifications/service.py @@ -62,7 +62,7 @@ async def send_to_user( ) session.add(notification) - await session.commit() + await session.flush() enqueue_job("notifications.send", notification_id=notification.id) return True @@ -95,7 +95,7 @@ async def send_to_anonymous_email( ) session.add(notification) - await session.commit() + await session.flush() enqueue_job("notifications.send", notification_id=notification.id) async def send_to_pledger( @@ -155,7 +155,6 @@ async def set_user_last_read( ) ) await session.execute(stmt) - await session.commit() notifications = NotificationsService() diff --git a/server/polar/user/service/user.py b/server/polar/user/service/user.py index 82176d35b7..71b7a7b532 100644 --- a/server/polar/user/service/user.py +++ b/server/polar/user/service/user.py @@ -120,7 +120,6 @@ async def set_account( user.account = account session.add(user) - await session.commit() return user async def link_customers(self, session: AsyncSession, user: User) -> None: diff --git a/server/polar/user_organization/service.py b/server/polar/user_organization/service.py index f0fcdeb651..ad1481cbed 100644 --- a/server/polar/user_organization/service.py +++ b/server/polar/user_organization/service.py @@ -85,7 +85,6 @@ async def remove_member( .values(deleted_at=utc_now()) ) await session.execute(stmt) - await session.commit() def _get_list_by_user_id_query( self, user_id: UUID, ordered: bool = True From 54e461926087c8e0ba51d022b396e70e81a092e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Wed, 18 Dec 2024 15:04:43 +0100 Subject: [PATCH 2/4] server: remove Posthog integration with Sentry Was not really working anymore + didn't prove very useful --- server/polar/sentry.py | 101 ----------------------------------------- 1 file changed, 101 deletions(-) diff --git a/server/polar/sentry.py b/server/polar/sentry.py index d400d28eda..c4d8c2deba 100644 --- a/server/polar/sentry.py +++ b/server/polar/sentry.py @@ -1,114 +1,14 @@ import os -from typing import TYPE_CHECKING, Self -import posthog as global_posthog import sentry_sdk -from posthog.request import DEFAULT_HOST -from sentry_sdk.hub import Hub -from sentry_sdk.integrations import Integration from sentry_sdk.integrations.fastapi import FastApiIntegration -from sentry_sdk.scope import add_global_event_processor -from sentry_sdk.utils import Dsn from polar.auth.models import AuthSubject, Subject, is_user from polar.config import settings -from polar.posthog import posthog - -if TYPE_CHECKING: - from posthog import Posthog - from sentry_sdk import _types POSTHOG_ID_TAG = "posthog_distinct_id" -class PostHogIntegration(Integration): - """ - PostHog integration for Sentry, heavily pulled from the official one from PostHog. - - https://github.com/PostHog/posthog-python/blob/master/posthog/sentry/posthog_integration.py - - The official one suffers from a few limitations: - - * Doesn't have a clean way to set dynamic parameters, like `organization`. - * Doesn't support a custom instance of PostHog, only the global one. - * Tries to serialize the Sentry exception object, but fails to do so. - - This implementation tries to solve those limitations to fit our use-case. - """ - - identifier = "posthog-python" - - def __init__( - self, - posthog: "Posthog | None" = None, - organization: str | None = None, - project_id: str | None = None, - prefix: str = "https://sentry.io/organizations/", - ): - self.posthog = posthog if posthog else global_posthog - self.organization = organization - self.project_id = project_id - self.prefix = prefix - - @staticmethod - def setup_once() -> None: - @add_global_event_processor - def processor(event: "_types.Event", hint: "_types.Hint") -> "_types.Event": - integration: Self | None = Hub.current.get_integration(PostHogIntegration) - if integration is not None: - if event.get("level") != "error": - return event - - if event.get("tags", {}).get(POSTHOG_ID_TAG): - posthog = integration.posthog - - posthog_distinct_id = event["tags"][POSTHOG_ID_TAG] - - # Posthog and Module("Posthog") are not compatible types in Python 3.12 / Mypy 1.7 - # Adding if/else here as a workaround - host = ( - posthog.host - if posthog and isinstance(posthog, Posthog) - else global_posthog.host - ) - - event["tags"]["PostHog URL"] = ( - f"{host or DEFAULT_HOST}/person/{posthog_distinct_id}" - ) - - properties = { - "$sentry_event_id": event["event_id"], - } - - if integration.organization: - project_id = integration.project_id - if project_id is None: - sentry_client = Hub.current.client - if ( - sentry_client is not None - and sentry_client.dsn is not None - ): - project_id = Dsn(sentry_client.dsn).project_id - - if project_id: - properties["$sentry_url"] = ( - f"{integration.prefix}{integration.organization}" - "/issues/" - f"?project={project_id}&query={event['event_id']}" - ) - - # Posthog and Module("Posthog") are not compatible types in Python 3.12 / Mypy 1.7 - # Adding if/else here as a workaround - if posthog and isinstance(posthog, Posthog): - posthog.capture(posthog_distinct_id, "$exception", properties) - else: - global_posthog.capture( - posthog_distinct_id, "$exception", properties - ) - - return event - - def configure_sentry() -> None: sentry_sdk.init( dsn=settings.SENTRY_DSN, @@ -119,7 +19,6 @@ def configure_sentry() -> None: server_name=os.environ.get("RENDER_INSTANCE_ID", "localhost"), environment=settings.ENV, integrations=[ - PostHogIntegration(posthog=posthog.client, organization="polar-sh"), FastApiIntegration(transaction_style="endpoint"), ], ) From e7cab08f17d5ac809a95dcc19a5007d35ead23c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Wed, 18 Dec 2024 15:04:52 +0100 Subject: [PATCH 3/4] server/tests: fix HTTPX depreciation warning --- server/tests/fixtures/base.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/tests/fixtures/base.py b/server/tests/fixtures/base.py index 99530c41c1..4d82f5afaa 100644 --- a/server/tests/fixtures/base.py +++ b/server/tests/fixtures/base.py @@ -1,10 +1,10 @@ from collections.abc import AsyncGenerator from typing import Any +import httpx import pytest import pytest_asyncio from fastapi import FastAPI -from httpx import AsyncClient from polar.app import app as polar_app from polar.auth.dependencies import _auth_subject_factory_cache @@ -16,9 +16,7 @@ @pytest_asyncio.fixture async def app( - auth_subject: AuthSubject[Subject], - session: AsyncSession, - redis: Redis, + auth_subject: AuthSubject[Subject], session: AsyncSession, redis: Redis ) -> AsyncGenerator[FastAPI]: polar_app.dependency_overrides[get_db_session] = lambda: session polar_app.dependency_overrides[get_redis] = lambda: redis @@ -34,7 +32,7 @@ async def app( @pytest_asyncio.fixture async def client( app: FastAPI, request: pytest.FixtureRequest, session: AsyncSession -) -> AsyncGenerator[AsyncClient, None]: +) -> AsyncGenerator[httpx.AsyncClient, None]: request_hooks = [] async def expunge_hook(request: Any) -> None: @@ -52,8 +50,8 @@ async def expunge_hook(request: Any) -> None: if auto_expunge_marker.args != (False,): request_hooks.append(expunge_hook) - async with AsyncClient( - app=app, + async with httpx.AsyncClient( + transport=httpx.ASGITransport(app=app), base_url="http://test", event_hooks={"request": request_hooks}, ) as client: From a08d35983243908f1c5591f418ef19fadcc66deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Wed, 18 Dec 2024 15:14:38 +0100 Subject: [PATCH 4/4] server/tests: remove expunge assertions in tests This made writing tests really painful and didn't bring much value --- server/pyproject.toml | 3 -- server/tests/account/test_endpoints.py | 9 ------ server/tests/benefit/benefits/test_ads.py | 1 - .../benefit/benefits/test_downloadables.py | 1 - .../benefit/service/test_benefit_grant.py | 1 - server/tests/benefit/test_endpoints.py | 5 ---- .../tests/checkout/legacy/test_endpoints.py | 2 -- server/tests/checkout/legacy/test_service.py | 2 -- server/tests/checkout/test_endpoints.py | 7 ----- server/tests/checkout/test_service.py | 9 ------ server/tests/checkout_link/test_endpoints.py | 4 --- server/tests/checkout_link/test_service.py | 3 -- server/tests/custom_field/test_data.py | 3 -- server/tests/custom_field/test_schemas.py | 2 -- server/tests/custom_field/test_service.py | 1 - server/tests/customer/test_service.py | 2 -- .../endpoints/test_benefit_grant.py | 1 - .../endpoints/test_downloadables.py | 1 - .../endpoints/test_license_keys.py | 1 - .../service/test_benefit_grant.py | 2 -- .../customer_portal/service/test_order.py | 2 -- .../service/test_subscription.py | 3 -- server/tests/dashboard/test_endpoints.py | 11 ------- server/tests/discount/test_service.py | 4 --- .../external_organization/test_service.py | 1 - server/tests/file/test_endpoints.py | 1 - server/tests/fixtures/base.py | 29 ++----------------- server/tests/fixtures/database.py | 21 +------------- server/tests/funding/test_endpoints.py | 1 - .../github/service/test_secret_scanning.py | 2 -- .../tests/integrations/github/test_badge.py | 7 ----- .../integrations/github/test_endpoints.py | 1 - server/tests/issue/test_endpoints.py | 8 ----- server/tests/license_key/test_endpoints.py | 1 - server/tests/magic_link/test_endpoints.py | 4 --- server/tests/metrics/test_endpoints.py | 2 -- server/tests/metrics/test_service.py | 1 - server/tests/models/test_base.py | 1 - server/tests/models/test_checkout.py | 1 - server/tests/models/test_pledge.py | 1 - server/tests/notifications/test_email.py | 20 ------------- server/tests/notifications/test_endpoints.py | 1 - .../list/test_list_oauth2_clients.py | 1 - server/tests/oauth2/endpoints/test_oauth2.py | 7 ----- .../tests/oauth2/endpoints/test_well_known.py | 2 -- .../endpoints/userinfo/test_userinfo.py | 1 - .../service/test_oauth2_authorization_code.py | 1 - .../oauth2/service/test_oauth2_client.py | 1 - .../tests/oauth2/service/test_oauth2_token.py | 1 - server/tests/order/test_endpoints.py | 3 -- server/tests/order/test_service.py | 3 -- server/tests/organization/test_endpoints.py | 5 ---- server/tests/organization/test_service.py | 1 - .../personal_access_token/test_endpoints.py | 1 - .../personal_access_token/test_service.py | 1 - server/tests/pledge/test_endpoints.py | 11 ------- server/tests/product/service/test_product.py | 3 -- server/tests/product/test_endpoints.py | 5 ---- server/tests/repository/test_endpoints.py | 1 - server/tests/subscription/test_endpoints.py | 1 - server/tests/subscription/test_service.py | 1 - server/tests/test_openapi.py | 1 - .../tests/transaction/service/test_dispute.py | 1 - .../tests/transaction/service/test_payout.py | 1 - .../tests/transaction/service/test_refund.py | 1 - server/tests/transaction/test_endpoints.py | 4 --- server/tests/user/endpoints/test_user.py | 5 ---- server/tests/user/service/test_service.py | 1 - server/tests/webhooks/test_endpoints.py | 5 ---- server/tests/webhooks/test_service.py | 5 ---- server/tests/webhooks/test_webhooks.py | 4 --- 71 files changed, 3 insertions(+), 258 deletions(-) diff --git a/server/pyproject.toml b/server/pyproject.toml index 02a51092d7..72a4fb4530 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -99,9 +99,6 @@ pre_deploy = { cmd = "task db_migrate", help = "Pre-deploy command run by Render [tool.pytest.ini_options] markers = [ "auth", - "http_auto_expunge", - "skip_db_asserts", - "override_current_user", "email_order_confirmation", "email_subscription_confirmation", ] diff --git a/server/tests/account/test_endpoints.py b/server/tests/account/test_endpoints.py index 551a40d060..92ea9d0fc8 100644 --- a/server/tests/account/test_endpoints.py +++ b/server/tests/account/test_endpoints.py @@ -23,7 +23,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_create_invalid_account_type(client: AsyncClient) -> None: response = await client.post( @@ -39,7 +38,6 @@ async def test_create_invalid_account_type(client: AsyncClient) -> None: @pytest.mark.asyncio @pytest.mark.parametrize("slug", [None, ""]) -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_create_open_collective_missing_slug( slug: str | None, client: AsyncClient @@ -57,7 +55,6 @@ async def test_create_open_collective_missing_slug( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.parametrize( "error", [ @@ -88,7 +85,6 @@ async def test_create_open_collective_get_collective_error( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.parametrize( "collective", [ @@ -137,7 +133,6 @@ async def test_create_open_collective_not_eligible( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_create_open_collective( session: AsyncSession, mocker: MockerFixture, client: AsyncClient @@ -173,7 +168,6 @@ async def test_create_open_collective( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_create_personal_stripe( user: User, @@ -211,7 +205,6 @@ def to_dict(self) -> dict[str, Any]: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_onboarding_link_open_collective( open_collective_account: Account, client: AsyncClient @@ -225,7 +218,6 @@ async def test_onboarding_link_open_collective( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_dashboard_link_not_existing_account( user: User, @@ -241,7 +233,6 @@ async def test_dashboard_link_not_existing_account( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_dashboard_link_open_collective( open_collective_account: Account, client: AsyncClient diff --git a/server/tests/benefit/benefits/test_ads.py b/server/tests/benefit/benefits/test_ads.py index 34b3cff90c..044a8f1d12 100644 --- a/server/tests/benefit/benefits/test_ads.py +++ b/server/tests/benefit/benefits/test_ads.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_grant( session: AsyncSession, redis: Redis, diff --git a/server/tests/benefit/benefits/test_downloadables.py b/server/tests/benefit/benefits/test_downloadables.py index 0dcd2592ef..a042a074e7 100644 --- a/server/tests/benefit/benefits/test_downloadables.py +++ b/server/tests/benefit/benefits/test_downloadables.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestDownloadblesBenefit: @pytest.mark.auth async def test_grant_one( diff --git a/server/tests/benefit/service/test_benefit_grant.py b/server/tests/benefit/service/test_benefit_grant.py index 4a05c56592..2344d6cc34 100644 --- a/server/tests/benefit/service/test_benefit_grant.py +++ b/server/tests/benefit/service/test_benefit_grant.py @@ -322,7 +322,6 @@ async def test_several_benefit_grants_should_individual_revoke( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestEnqueueBenefitsGrants: @pytest.mark.parametrize("task", ["grant", "revoke"]) async def test_subscription_scope( diff --git a/server/tests/benefit/test_endpoints.py b/server/tests/benefit/test_endpoints.py index f41404bf0b..83a279fdc6 100644 --- a/server/tests/benefit/test_endpoints.py +++ b/server/tests/benefit/test_endpoints.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListBenefits: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/benefits/") @@ -67,7 +66,6 @@ async def test_organization( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetBenefit: async def test_anonymous( self, client: AsyncClient, benefit_organization: Benefit @@ -99,7 +97,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestCreateBenefit: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.post( @@ -172,7 +169,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestUpdateBenefit: async def test_anonymous( self, @@ -277,7 +273,6 @@ async def test_can_update_custom_properties( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestDeleteBenefit: async def test_anonymous( self, diff --git a/server/tests/checkout/legacy/test_endpoints.py b/server/tests/checkout/legacy/test_endpoints.py index 1ae9693515..130f4d8deb 100644 --- a/server/tests/checkout/legacy/test_endpoints.py +++ b/server/tests/checkout/legacy/test_endpoints.py @@ -18,7 +18,6 @@ def stripe_service_mock(mocker: MockerFixture) -> MagicMock: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestCreateCheckout: async def test_not_existing(self, client: AsyncClient) -> None: response = await client.post( @@ -101,7 +100,6 @@ async def test_anonymous_product_organization( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetCheckout: async def test_valid_product_organization( self, diff --git a/server/tests/checkout/legacy/test_service.py b/server/tests/checkout/legacy/test_service.py index a979175a3c..5c18dfc110 100644 --- a/server/tests/checkout/legacy/test_service.py +++ b/server/tests/checkout/legacy/test_service.py @@ -29,7 +29,6 @@ def stripe_service_mock(mocker: MockerFixture) -> MagicMock: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: async def test_not_existing_price( self, auth_subject: AuthSubject[Anonymous], session: AsyncSession @@ -355,7 +354,6 @@ async def test_valid_tax_not_applicable( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetById: @pytest.mark.parametrize("metadata", [None, {}, {"product_id": str(uuid.uuid4())}]) async def test_invalid( diff --git a/server/tests/checkout/test_endpoints.py b/server/tests/checkout/test_endpoints.py index 81f4d896ad..dc1101ebca 100644 --- a/server/tests/checkout/test_endpoints.py +++ b/server/tests/checkout/test_endpoints.py @@ -43,7 +43,6 @@ async def checkout_open( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGet: async def test_anonymous( self, client: AsyncClient, checkout_open: Checkout @@ -77,7 +76,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateCheckout: async def test_anonymous(self, client: AsyncClient, product: Product) -> None: response = await client.post( @@ -127,7 +125,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateCheckout: async def test_anonymous( self, client: AsyncClient, checkout_open: Checkout @@ -193,7 +190,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestClientGet: async def test_not_existing(self, client: AsyncClient) -> None: response = await client.get(f"{API_PREFIX}/client/123") @@ -213,7 +209,6 @@ async def test_valid(self, client: AsyncClient, checkout_open: Checkout) -> None @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestClientCreateCheckout: @pytest.mark.auth(AuthSubjectFixture(subject="user", scopes=set())) async def test_missing_scope(self, client: AsyncClient, product: Product) -> None: @@ -251,7 +246,6 @@ async def test_user( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestClientUpdate: async def test_not_existing(self, client: AsyncClient) -> None: response = await client.patch( @@ -283,7 +277,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestClientConfirm: async def test_not_existing(self, client: AsyncClient) -> None: response = await client.post( diff --git a/server/tests/checkout/test_service.py b/server/tests/checkout/test_service.py index a8936867e4..4888481c66 100644 --- a/server/tests/checkout/test_service.py +++ b/server/tests/checkout/test_service.py @@ -229,7 +229,6 @@ async def checkout_tax_not_applicable( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: @pytest.mark.auth async def test_not_existing_price( @@ -1062,7 +1061,6 @@ async def test_customer_metadata( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestClientCreate: async def test_not_existing_price( self, session: AsyncSession, auth_subject: AuthSubject[Anonymous] @@ -1272,7 +1270,6 @@ async def test_user_with_customer( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCheckoutLinkCreate: async def test_archived_price( self, @@ -1349,7 +1346,6 @@ async def test_valid_with_discount( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_not_existing_price( self, @@ -1852,7 +1848,6 @@ async def test_valid_discount_code( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestConfirm: async def test_missing_amount_on_custom_price( self, @@ -2298,7 +2293,6 @@ def build_stripe_payment_intent( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestHandleStripeSuccess: async def test_not_existing_checkout(self, session: AsyncSession) -> None: with pytest.raises(CheckoutDoesNotExist): @@ -2458,7 +2452,6 @@ async def test_valid_recurring_upgrade( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestHandleStripeFailure: async def test_not_existing_checkout(self, session: AsyncSession) -> None: with pytest.raises(CheckoutDoesNotExist): @@ -2492,7 +2485,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestHandleFreeSuccess: async def test_not_existing_checkout(self, session: AsyncSession) -> None: with pytest.raises(CheckoutDoesNotExist): @@ -2613,7 +2605,6 @@ async def test_valid_discount_percentage_100( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestExpireOpenCheckouts: async def test_valid( self, save_fixture: SaveFixture, session: AsyncSession, product: Product diff --git a/server/tests/checkout_link/test_endpoints.py b/server/tests/checkout_link/test_endpoints.py index 7a0566dee6..a99600d643 100644 --- a/server/tests/checkout_link/test_endpoints.py +++ b/server/tests/checkout_link/test_endpoints.py @@ -22,7 +22,6 @@ async def checkout_link(save_fixture: SaveFixture, product: Product) -> Checkout @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateCheckoutLink: async def test_anonymous(self, client: AsyncClient, product: Product) -> None: response = await client.post( @@ -120,7 +119,6 @@ async def test_valid_with_price( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateCheckoutLink: async def test_anonymous( self, client: AsyncClient, checkout_link: CheckoutLink @@ -189,7 +187,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestDeleteCheckoutLink: async def test_anonymous( self, client: AsyncClient, checkout_link: CheckoutLink @@ -235,7 +232,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRedirect: def client_secret_from_redirect_url(self, url: str) -> str: client_secret = url.split("/")[-1] diff --git a/server/tests/checkout_link/test_service.py b/server/tests/checkout_link/test_service.py index b28f1af182..15a7678503 100644 --- a/server/tests/checkout_link/test_service.py +++ b/server/tests/checkout_link/test_service.py @@ -33,7 +33,6 @@ async def checkout_link(save_fixture: SaveFixture, product: Product) -> Checkout @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: @pytest.mark.auth async def test_not_existing_price( @@ -180,7 +179,6 @@ async def test_valid_discount( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_update_metadata( self, @@ -296,7 +294,6 @@ async def test_set_discount( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestDelete: async def test_valid( self, session: AsyncSession, checkout_link: CheckoutLink diff --git a/server/tests/custom_field/test_data.py b/server/tests/custom_field/test_data.py index 03b673a948..3b07b874f1 100644 --- a/server/tests/custom_field/test_data.py +++ b/server/tests/custom_field/test_data.py @@ -55,7 +55,6 @@ async def custom_field_data_schema( ) -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "input", ( @@ -72,7 +71,6 @@ def test_invalid_input( custom_field_data_schema.model_validate(input) -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "input", ( @@ -89,7 +87,6 @@ def test_valid_input( assert data.model_dump(exclude_unset=True) == input -@pytest.mark.skip_db_asserts @pytest.mark.asyncio async def test_checkbox_input( save_fixture: SaveFixture, organization: Organization diff --git a/server/tests/custom_field/test_schemas.py b/server/tests/custom_field/test_schemas.py index 4407921453..3532d935e7 100644 --- a/server/tests/custom_field/test_schemas.py +++ b/server/tests/custom_field/test_schemas.py @@ -11,7 +11,6 @@ ) -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "input", ( @@ -53,7 +52,6 @@ def test_invalid_create(input: dict[str, Any]) -> None: ) -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "input,expected_type", ( diff --git a/server/tests/custom_field/test_service.py b/server/tests/custom_field/test_service.py index 0e25a6e778..74b3e11f91 100644 --- a/server/tests/custom_field/test_service.py +++ b/server/tests/custom_field/test_service.py @@ -40,7 +40,6 @@ async def order_text_field_data( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_slug_update( self, diff --git a/server/tests/customer/test_service.py b/server/tests/customer/test_service.py index efbd2fd7ad..0b5aa2ce9e 100644 --- a/server/tests/customer/test_service.py +++ b/server/tests/customer/test_service.py @@ -18,7 +18,6 @@ def authz(session: AsyncSession) -> Authz: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: @pytest.mark.auth async def test_not_accessible_organization( @@ -92,7 +91,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_existing_email( self, session: AsyncSession, customer: Customer, customer_second: Customer diff --git a/server/tests/customer_portal/endpoints/test_benefit_grant.py b/server/tests/customer_portal/endpoints/test_benefit_grant.py index e941487ea3..d8717ea893 100644 --- a/server/tests/customer_portal/endpoints/test_benefit_grant.py +++ b/server/tests/customer_portal/endpoints/test_benefit_grant.py @@ -8,7 +8,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestListBenefitGrants: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_customer( diff --git a/server/tests/customer_portal/endpoints/test_downloadables.py b/server/tests/customer_portal/endpoints/test_downloadables.py index a69747fc35..0785ca06bf 100644 --- a/server/tests/customer_portal/endpoints/test_downloadables.py +++ b/server/tests/customer_portal/endpoints/test_downloadables.py @@ -18,7 +18,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestDownloadablesEndpoints: async def test_anonymous_list_401s(self, client: AsyncClient) -> None: response = await client.get("/v1/customer-portal/downloadables/") diff --git a/server/tests/customer_portal/endpoints/test_license_keys.py b/server/tests/customer_portal/endpoints/test_license_keys.py index c4425a032c..8aaeb7559e 100644 --- a/server/tests/customer_portal/endpoints/test_license_keys.py +++ b/server/tests/customer_portal/endpoints/test_license_keys.py @@ -20,7 +20,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestCustomerLicenseKeyEndpoints: async def test_validate( self, diff --git a/server/tests/customer_portal/service/test_benefit_grant.py b/server/tests/customer_portal/service/test_benefit_grant.py index 8461875560..33b049db22 100644 --- a/server/tests/customer_portal/service/test_benefit_grant.py +++ b/server/tests/customer_portal/service/test_benefit_grant.py @@ -15,7 +15,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestList: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_other_customer( @@ -121,7 +120,6 @@ async def test_sorting( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetById: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_other_customer( diff --git a/server/tests/customer_portal/service/test_order.py b/server/tests/customer_portal/service/test_order.py index 3bf967d911..bdd72a20d7 100644 --- a/server/tests/customer_portal/service/test_order.py +++ b/server/tests/customer_portal/service/test_order.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestList: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_other_customer( @@ -82,7 +81,6 @@ async def test_sorting( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetById: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_other_customer( diff --git a/server/tests/customer_portal/service/test_subscription.py b/server/tests/customer_portal/service/test_subscription.py index 43a2929ad2..fd9cd8d91d 100644 --- a/server/tests/customer_portal/service/test_subscription.py +++ b/server/tests/customer_portal/service/test_subscription.py @@ -47,7 +47,6 @@ def stripe_service_mock(mocker: MockerFixture) -> MagicMock: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestList: @pytest.mark.auth(AuthSubjectFixture(subject="customer")) async def test_valid( @@ -93,7 +92,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_not_existing_product( self, session: AsyncSession, subscription: Subscription @@ -187,7 +185,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCancel: @pytest.mark.auth async def test_already_canceled( diff --git a/server/tests/dashboard/test_endpoints.py b/server/tests/dashboard/test_endpoints.py index 9d91304857..1ea2c52ea3 100644 --- a/server/tests/dashboard/test_endpoints.py +++ b/server/tests/dashboard/test_endpoints.py @@ -20,7 +20,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get( user: User, @@ -39,7 +38,6 @@ async def test_get( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_personal(client: AsyncClient) -> None: response = await client.get("/v1/dashboard/personal") @@ -48,7 +46,6 @@ async def test_get_personal(client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_no_member( user: User, @@ -63,7 +60,6 @@ async def test_get_no_member( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_with_pledge_from_org( user: User, @@ -93,7 +89,6 @@ async def test_get_with_pledge_from_org( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_with_pledge_from_user( save_fixture: SaveFixture, @@ -134,7 +129,6 @@ async def test_get_with_pledge_from_user( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_with_pledge_from_user_github_oauth( user: User, @@ -178,7 +172,6 @@ async def test_get_with_pledge_from_user_github_oauth( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_with_pledge_initiated( user: User, @@ -207,7 +200,6 @@ async def test_get_with_pledge_initiated( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_only_pledged_with_pledge( user: User, @@ -237,7 +229,6 @@ async def test_get_only_pledged_with_pledge( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_only_pledged_no_pledge( user: User, @@ -260,7 +251,6 @@ async def test_get_only_pledged_no_pledge( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_only_badged_no_badge( user: User, @@ -283,7 +273,6 @@ async def test_get_only_badged_no_badge( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_only_badged_is_badged( user: User, diff --git a/server/tests/discount/test_service.py b/server/tests/discount/test_service.py index 0f14da10f5..d4863abea9 100644 --- a/server/tests/discount/test_service.py +++ b/server/tests/discount/test_service.py @@ -39,7 +39,6 @@ def stripe_service_mock(mocker: MockerFixture) -> MagicMock: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: async def test_duration_change( self, @@ -255,7 +254,6 @@ async def test_update_products_reset( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestIsRedeemableDiscount: async def test_not_started( self, @@ -355,7 +353,6 @@ async def test_redeemable( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRedeemDiscount: async def test_concurrency( self, @@ -411,7 +408,6 @@ async def _redemption_task( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCodeCaseInsensitivity: async def test_code_case_insensitive( self, diff --git a/server/tests/external_organization/test_service.py b/server/tests/external_organization/test_service.py index 941c29b6d5..b5b809afb8 100644 --- a/server/tests/external_organization/test_service.py +++ b/server/tests/external_organization/test_service.py @@ -11,7 +11,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestList: @pytest.mark.auth( AuthSubjectFixture(subject="anonymous"), diff --git a/server/tests/file/test_endpoints.py b/server/tests/file/test_endpoints.py index 116548d9fd..f42a7f12ab 100644 --- a/server/tests/file/test_endpoints.py +++ b/server/tests/file/test_endpoints.py @@ -12,7 +12,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestEndpoints: async def test_anonymous_create_401( self, client: AsyncClient, organization: Organization diff --git a/server/tests/fixtures/base.py b/server/tests/fixtures/base.py index 4d82f5afaa..0f6f608cf8 100644 --- a/server/tests/fixtures/base.py +++ b/server/tests/fixtures/base.py @@ -1,8 +1,6 @@ from collections.abc import AsyncGenerator -from typing import Any import httpx -import pytest import pytest_asyncio from fastapi import FastAPI @@ -30,31 +28,8 @@ async def app( @pytest_asyncio.fixture -async def client( - app: FastAPI, request: pytest.FixtureRequest, session: AsyncSession -) -> AsyncGenerator[httpx.AsyncClient, None]: - request_hooks = [] - - async def expunge_hook(request: Any) -> None: - session.expunge_all() - return None - - # add @pytest.mark.http_auto_expunge() to a test to add auto-expunging on the first - # httpx request. - # - # This should only be used if the test doesn't use "session" directly, and only makes - # a single HTTP request. - auto_expunge_marker = request.node.get_closest_marker("http_auto_expunge") - if auto_expunge_marker is not None: - # can be disabled with @pytest.mark.http_auto_expunge(False) - if auto_expunge_marker.args != (False,): - request_hooks.append(expunge_hook) - +async def client(app: FastAPI) -> AsyncGenerator[httpx.AsyncClient, None]: async with httpx.AsyncClient( - transport=httpx.ASGITransport(app=app), - base_url="http://test", - event_hooks={"request": request_hooks}, + transport=httpx.ASGITransport(app=app), base_url="http://test" ) as client: - client.event_hooks - yield client diff --git a/server/tests/fixtures/database.py b/server/tests/fixtures/database.py index 2474f8bfcd..03ffffc90a 100644 --- a/server/tests/fixtures/database.py +++ b/server/tests/fixtures/database.py @@ -5,7 +5,6 @@ from pathlib import Path from uuid import UUID -import pytest import pytest_asyncio from pydantic_core import Url from pytest_mock import MockerFixture @@ -107,11 +106,7 @@ async def _spy_commit() -> None: @pytest_asyncio.fixture -async def session( - worker_id: str, - mocker: MockerFixture, - request: pytest.FixtureRequest, -) -> AsyncIterator[AsyncSession]: +async def session(worker_id: str, mocker: MockerFixture) -> AsyncIterator[AsyncSession]: engine = create_async_engine( dsn=get_database_url(worker_id), application_name=f"test_{worker_id}", @@ -123,7 +118,6 @@ async def session( session = AsyncSession(bind=connection, expire_on_commit=False) - expunge_spy = mocker.spy(session, "expunge_all") mocker.patch.object( session, "commit", side_effect=session_commit_spy(session.commit) ) @@ -134,19 +128,6 @@ async def session( await connection.close() await engine.dispose() - skip_db_assert_marker = request.node.get_closest_marker("skip_db_asserts") - if skip_db_assert_marker is not None: - return - - # Assert that session.expunge_all() was called. - # - # expunge_all() should be called after the test has been setup, and before - # the test calls out to the implementation. - # - # This is to ensure that we don't rely on the existing state in the Session - # from creating the tests. - expunge_spy.assert_called() - SaveFixture = Callable[[Model], Coroutine[None, None, None]] diff --git a/server/tests/funding/test_endpoints.py b/server/tests/funding/test_endpoints.py index 9d72228e38..90feaa07a1 100644 --- a/server/tests/funding/test_endpoints.py +++ b/server/tests/funding/test_endpoints.py @@ -17,7 +17,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestSearch: async def test_unknown_organization(self, client: AsyncClient) -> None: response = await client.get( diff --git a/server/tests/integrations/github/service/test_secret_scanning.py b/server/tests/integrations/github/service/test_secret_scanning.py index e36540b225..aaf8b110ab 100644 --- a/server/tests/integrations/github/service/test_secret_scanning.py +++ b/server/tests/integrations/github/service/test_secret_scanning.py @@ -27,7 +27,6 @@ def generate_signature(payload: str, key: ec.EllipticCurvePrivateKey) -> str: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestVerifySignature: async def test_invalid_signature(self, mocker: MockerFixture) -> None: mocker.patch.object( @@ -65,7 +64,6 @@ async def test_valid(self, mocker: MockerFixture) -> None: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestValidatePayload: @pytest.mark.parametrize( "payload", diff --git a/server/tests/integrations/github/test_badge.py b/server/tests/integrations/github/test_badge.py index 0c0688f7e1..039b72791c 100644 --- a/server/tests/integrations/github/test_badge.py +++ b/server/tests/integrations/github/test_badge.py @@ -34,7 +34,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_add_badge( organization: Organization, external_organization_linked: ExternalOrganization, @@ -119,7 +118,6 @@ async def test_add_badge_custom_organization_content( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_remove_badge( organization: Organization, external_organization_linked: ExternalOrganization, @@ -137,7 +135,6 @@ async def test_remove_badge( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_remove_badge_custom_content( organization: Organization, external_organization_linked: ExternalOrganization, @@ -170,7 +167,6 @@ async def test_remove_badge_custom_content( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_remove_badge_pre_2023_05_08( organization: Organization, external_organization_linked: ExternalOrganization, @@ -198,7 +194,6 @@ async def test_remove_badge_pre_2023_05_08( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @patch("polar.config.settings.GITHUB_BADGE_EMBED", False) async def test_should_add_badge_app_config_disabled( session: AsyncSession, @@ -216,7 +211,6 @@ async def test_should_add_badge_app_config_disabled( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @patch("polar.config.settings.GITHUB_BADGE_EMBED", True) async def test_should_add_badge_org_not_installed( session: AsyncSession, @@ -242,7 +236,6 @@ async def test_should_add_badge_org_not_installed( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @patch("polar.config.settings.GITHUB_BADGE_EMBED", True) async def test_should_add_badge_no_badge_with_auto( save_fixture: SaveFixture, diff --git a/server/tests/integrations/github/test_endpoints.py b/server/tests/integrations/github/test_endpoints.py index 71e56f80d4..e9e8051889 100644 --- a/server/tests/integrations/github/test_endpoints.py +++ b/server/tests/integrations/github/test_endpoints.py @@ -7,7 +7,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestSecretScanning: @pytest.mark.parametrize( "headers", diff --git a/server/tests/issue/test_endpoints.py b/server/tests/issue/test_endpoints.py index d75cdb7efd..e8b602dbb6 100644 --- a/server/tests/issue/test_endpoints.py +++ b/server/tests/issue/test_endpoints.py @@ -15,7 +15,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_issue( external_organization: ExternalOrganization, @@ -38,7 +37,6 @@ async def test_get_issue( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_issue_reactions( repository: Repository, @@ -70,7 +68,6 @@ async def test_get_issue_reactions( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_not_found_private_repo( organization: Organization, @@ -88,7 +85,6 @@ async def test_get_not_found_private_repo( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_private_repo_member( repository_linked: Repository, @@ -107,7 +103,6 @@ async def test_get_private_repo_member( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_issue_list_public_repo( organization: Organization, @@ -139,7 +134,6 @@ async def test_issue_list_public_repo( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_issue_list_public_repo_without_repo_selector( organization: Organization, @@ -165,7 +159,6 @@ async def test_issue_list_public_repo_without_repo_selector( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_issue_list_private_repo( organization: Organization, @@ -190,7 +183,6 @@ async def test_issue_list_private_repo( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_issue_list_private_repo_without_repo_selector( organization: Organization, diff --git a/server/tests/license_key/test_endpoints.py b/server/tests/license_key/test_endpoints.py index 3c6b06a6e7..88004c436d 100644 --- a/server/tests/license_key/test_endpoints.py +++ b/server/tests/license_key/test_endpoints.py @@ -21,7 +21,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestLicenseKeyEndpoints: @pytest.mark.auth( AuthSubjectFixture(subject="user"), diff --git a/server/tests/magic_link/test_endpoints.py b/server/tests/magic_link/test_endpoints.py index eef0aa71f5..905d5c7292 100644 --- a/server/tests/magic_link/test_endpoints.py +++ b/server/tests/magic_link/test_endpoints.py @@ -12,7 +12,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_request(client: AsyncClient, mocker: MockerFixture) -> None: magic_link_service_request_mock = mocker.patch.object( magic_link_service, @@ -44,7 +43,6 @@ async def test_request(client: AsyncClient, mocker: MockerFixture) -> None: @pytest.mark.asyncio @pytest.mark.auth -@pytest.mark.http_auto_expunge async def test_authenticate_already_authenticated( client: AsyncClient, user: User, mocker: MockerFixture ) -> None: @@ -61,7 +59,6 @@ async def test_authenticate_already_authenticated( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_authenticate_invalid_token( client: AsyncClient, mocker: MockerFixture ) -> None: @@ -81,7 +78,6 @@ async def test_authenticate_invalid_token( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_authenticate_valid_token( client: AsyncClient, user: User, mocker: MockerFixture ) -> None: diff --git a/server/tests/metrics/test_endpoints.py b/server/tests/metrics/test_endpoints.py index ddf6f12dc0..a02504fce4 100644 --- a/server/tests/metrics/test_endpoints.py +++ b/server/tests/metrics/test_endpoints.py @@ -8,7 +8,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetMetrics: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/metrics/") @@ -74,7 +73,6 @@ async def test_organization(self, client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetMetricsLimits: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/metrics/limits") diff --git a/server/tests/metrics/test_service.py b/server/tests/metrics/test_service.py index e9bb6d2144..3483800b6e 100644 --- a/server/tests/metrics/test_service.py +++ b/server/tests/metrics/test_service.py @@ -180,7 +180,6 @@ async def fixtures( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetMetrics: @pytest.mark.auth @pytest.mark.parametrize( diff --git a/server/tests/models/test_base.py b/server/tests/models/test_base.py index a88b93c3f6..9e57f9a3b1 100644 --- a/server/tests/models/test_base.py +++ b/server/tests/models/test_base.py @@ -4,6 +4,5 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_repr(user: User) -> None: assert repr(user) == f"User(id={user.id!r})" diff --git a/server/tests/models/test_checkout.py b/server/tests/models/test_checkout.py index 24b990c0dd..0d89d92659 100644 --- a/server/tests/models/test_checkout.py +++ b/server/tests/models/test_checkout.py @@ -10,7 +10,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "initial_status,expected_status", [ diff --git a/server/tests/models/test_pledge.py b/server/tests/models/test_pledge.py index 845bd1fdc0..dd02917fd8 100644 --- a/server/tests/models/test_pledge.py +++ b/server/tests/models/test_pledge.py @@ -7,7 +7,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @pytest.mark.parametrize( "test_amount", [1010, 12345678999], diff --git a/server/tests/notifications/test_email.py b/server/tests/notifications/test_email.py index 7a73bb103b..e7af624190 100644 --- a/server/tests/notifications/test_email.py +++ b/server/tests/notifications/test_email.py @@ -43,7 +43,6 @@ async def check_diff(email: tuple[str, str]) -> None: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeCreatedNotification_no_stripe( predictable_user: User, ) -> None: @@ -64,7 +63,6 @@ async def test_MaintainerPledgeCreatedNotification_no_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeCreatedNotification_with_stripe( predictable_user: User, ) -> None: @@ -85,7 +83,6 @@ async def test_MaintainerPledgeCreatedNotification_with_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeCreatedNotification_anonymous( predictable_user: User, ) -> None: @@ -106,7 +103,6 @@ async def test_MaintainerPledgeCreatedNotification_anonymous( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeCreatedNotification_pay_on_completion( predictable_user: User, ) -> None: @@ -127,7 +123,6 @@ async def test_MaintainerPledgeCreatedNotification_pay_on_completion( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeConfirmationPendingdNotification_no_stripe( predictable_user: User, ) -> None: @@ -147,7 +142,6 @@ async def test_MaintainerPledgeConfirmationPendingdNotification_no_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgeConfirmationPendingdNotification_with_stripe( predictable_user: User, ) -> None: @@ -167,7 +161,6 @@ async def test_MaintainerPledgeConfirmationPendingdNotification_with_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgePendingdNotification_no_stripe( predictable_user: User, ) -> None: @@ -187,7 +180,6 @@ async def test_MaintainerPledgePendingdNotification_no_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgePendingdNotification_with_stripe( predictable_user: User, ) -> None: @@ -207,7 +199,6 @@ async def test_MaintainerPledgePendingdNotification_with_stripe( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_PledgerPledgePendingNotification( predictable_user: User, ) -> None: @@ -227,7 +218,6 @@ async def test_PledgerPledgePendingNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_PledgerPledgePendingNotification_pay_on_completion( predictable_user: User, ) -> None: @@ -247,7 +237,6 @@ async def test_PledgerPledgePendingNotification_pay_on_completion( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgePaidNotification( predictable_user: User, ) -> None: @@ -265,7 +254,6 @@ async def test_MaintainerPledgePaidNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_RewardPaidNotification( predictable_user: User, ) -> None: @@ -284,7 +272,6 @@ async def test_RewardPaidNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgedIssueConfirmationPendingNotification( predictable_user: User, ) -> None: @@ -303,7 +290,6 @@ async def test_MaintainerPledgedIssueConfirmationPendingNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgedIssueConfirmationPendingNotification_with_account( predictable_user: User, ) -> None: @@ -322,7 +308,6 @@ async def test_MaintainerPledgedIssueConfirmationPendingNotification_with_accoun @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgedIssuePendingNotification( predictable_user: User, ) -> None: @@ -341,7 +326,6 @@ async def test_MaintainerPledgedIssuePendingNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerPledgedIssuePendingNotification_with_account( predictable_user: User, ) -> None: @@ -360,7 +344,6 @@ async def test_MaintainerPledgedIssuePendingNotification_with_account( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_TeamAdminMemberPledgedNotification( predictable_user: User, organization: Organization, @@ -381,7 +364,6 @@ async def test_TeamAdminMemberPledgedNotification( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerNewPaidSubscriptionNotification() -> None: n = MaintainerNewPaidSubscriptionNotificationPayload( subscriber_name="John Doe", @@ -395,7 +377,6 @@ async def test_MaintainerNewPaidSubscriptionNotification() -> None: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerNewProductSaleNotification() -> None: n = MaintainerNewProductSaleNotificationPayload( customer_name="birk@polar.sh", @@ -408,7 +389,6 @@ async def test_MaintainerNewProductSaleNotification() -> None: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_MaintainerCreateAccountNotificationPayload() -> None: n = MaintainerCreateAccountNotificationPayload( organization_name="orgname", diff --git a/server/tests/notifications/test_endpoints.py b/server/tests/notifications/test_endpoints.py index eed294d98c..a180730d55 100644 --- a/server/tests/notifications/test_endpoints.py +++ b/server/tests/notifications/test_endpoints.py @@ -3,7 +3,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get(client: AsyncClient) -> None: response = await client.get("/v1/notifications") diff --git a/server/tests/oauth2/endpoints/list/test_list_oauth2_clients.py b/server/tests/oauth2/endpoints/list/test_list_oauth2_clients.py index b189987a30..53fe90ffc7 100644 --- a/server/tests/oauth2/endpoints/list/test_list_oauth2_clients.py +++ b/server/tests/oauth2/endpoints/list/test_list_oauth2_clients.py @@ -31,7 +31,6 @@ async def oauth2_client(save_fixture: SaveFixture, user: User) -> OAuth2Client: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListOAuth2Clients: async def test_unauthenticated(self, client: AsyncClient) -> None: response = await client.get("/v1/oauth2/") diff --git a/server/tests/oauth2/endpoints/test_oauth2.py b/server/tests/oauth2/endpoints/test_oauth2.py index 0bf2586a1f..bb6e5c5115 100644 --- a/server/tests/oauth2/endpoints/test_oauth2.py +++ b/server/tests/oauth2/endpoints/test_oauth2.py @@ -83,7 +83,6 @@ async def create_oauth2_grant( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2Register: async def test_unauthenticated(self, client: AsyncClient) -> None: response = await client.post("/v1/oauth2/register", json={}) @@ -130,7 +129,6 @@ async def test_valid(self, redirect_uri: str, client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2ConfigureGet: async def test_unauthenticated( self, client: AsyncClient, oauth2_client: OAuth2Client @@ -191,7 +189,6 @@ async def test_user_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2ConfigurePut: async def test_token_valid( self, client: AsyncClient, oauth2_client: OAuth2Client @@ -235,7 +232,6 @@ async def test_user_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2ConfigureDelete: async def test_token_valid( self, client: AsyncClient, oauth2_client: OAuth2Client @@ -259,7 +255,6 @@ async def test_user_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2Authorize: async def test_unauthenticated( self, client: AsyncClient, oauth2_client: OAuth2Client @@ -509,7 +504,6 @@ async def test_not_granted_organization_prompt_none( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2Consent: async def test_unauthenticated(self, client: AsyncClient) -> None: response = await client.post("/v1/oauth2/consent") @@ -675,7 +669,6 @@ async def test_organization_allow( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestOAuth2Token: async def test_authorization_code_sub_user( self, diff --git a/server/tests/oauth2/endpoints/test_well_known.py b/server/tests/oauth2/endpoints/test_well_known.py index b545b8d9c0..19c91499f0 100644 --- a/server/tests/oauth2/endpoints/test_well_known.py +++ b/server/tests/oauth2/endpoints/test_well_known.py @@ -3,7 +3,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_jwks(client: AsyncClient) -> None: response = await client.get("/.well-known/jwks.json") @@ -17,7 +16,6 @@ async def test_jwks(client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_openid_configuration(client: AsyncClient) -> None: response = await client.get("/.well-known/openid-configuration") diff --git a/server/tests/oauth2/endpoints/userinfo/test_userinfo.py b/server/tests/oauth2/endpoints/userinfo/test_userinfo.py index b003a0ef9d..7264845856 100644 --- a/server/tests/oauth2/endpoints/userinfo/test_userinfo.py +++ b/server/tests/oauth2/endpoints/userinfo/test_userinfo.py @@ -31,7 +31,6 @@ async def oauth2_client(save_fixture: SaveFixture, user: User) -> OAuth2Client: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @pytest.mark.parametrize("method", ["GET", "POST"]) class TestOAuth2UserInfo: async def test_no_scope( diff --git a/server/tests/oauth2/service/test_oauth2_authorization_code.py b/server/tests/oauth2/service/test_oauth2_authorization_code.py index dcc7b31262..e9b1614a08 100644 --- a/server/tests/oauth2/service/test_oauth2_authorization_code.py +++ b/server/tests/oauth2/service/test_oauth2_authorization_code.py @@ -12,7 +12,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRevokeLeaked: async def test_false_positive(self, session: AsyncSession) -> None: result = await oauth2_authorization_code_service.revoke_leaked( diff --git a/server/tests/oauth2/service/test_oauth2_client.py b/server/tests/oauth2/service/test_oauth2_client.py index 30fe6b2b73..3058c530cd 100644 --- a/server/tests/oauth2/service/test_oauth2_client.py +++ b/server/tests/oauth2/service/test_oauth2_client.py @@ -11,7 +11,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRevokeLeaked: @pytest.mark.parametrize( "token, token_type", diff --git a/server/tests/oauth2/service/test_oauth2_token.py b/server/tests/oauth2/service/test_oauth2_token.py index 90fca4bb64..7292819f34 100644 --- a/server/tests/oauth2/service/test_oauth2_token.py +++ b/server/tests/oauth2/service/test_oauth2_token.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRevokeLeaked: @pytest.mark.parametrize( "token, token_type", diff --git a/server/tests/order/test_endpoints.py b/server/tests/order/test_endpoints.py index 8772ee8b40..532d90b78d 100644 --- a/server/tests/order/test_endpoints.py +++ b/server/tests/order/test_endpoints.py @@ -19,7 +19,6 @@ async def orders( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListOrders: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/orders/") @@ -67,7 +66,6 @@ async def test_organization(self, client: AsyncClient, orders: list[Order]) -> N @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetOrder: async def test_anonymous(self, client: AsyncClient, orders: list[Order]) -> None: response = await client.get(f"/v1/orders/{orders[0].id}") @@ -118,7 +116,6 @@ async def test_organization(self, client: AsyncClient, orders: list[Order]) -> N @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TesGetOrdersStatistics: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/orders/statistics") diff --git a/server/tests/order/test_service.py b/server/tests/order/test_service.py index aee9ba8a0b..ef32da1f04 100644 --- a/server/tests/order/test_service.py +++ b/server/tests/order/test_service.py @@ -133,7 +133,6 @@ def event_creation_time() -> tuple[datetime, int]: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestList: @pytest.mark.auth async def test_user_not_organization_member( @@ -270,7 +269,6 @@ async def test_organization( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateOrderFromStripe: @pytest.mark.parametrize( "metadata", @@ -1134,7 +1132,6 @@ async def test_with_checkout( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @pytest.mark.email_order_confirmation async def test_send_confirmation_email( mocker: MockerFixture, diff --git a/server/tests/organization/test_endpoints.py b/server/tests/organization/test_endpoints.py index ad5c633988..8a735bcd20 100644 --- a/server/tests/organization/test_endpoints.py +++ b/server/tests/organization/test_endpoints.py @@ -12,7 +12,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestListOrganizations: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/organizations/") @@ -48,7 +47,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetOrganization: async def test_anonymous( self, client: AsyncClient, organization: Organization @@ -93,7 +91,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateOrganization: @pytest.mark.auth async def test_not_existing(self, client: AsyncClient) -> None: @@ -128,7 +125,6 @@ async def test_valid_user( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_list_members( session: AsyncSession, @@ -146,7 +142,6 @@ async def test_list_members( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_list_members_not_member( session: AsyncSession, diff --git a/server/tests/organization/test_service.py b/server/tests/organization/test_service.py index 9f78fa424e..5fe691a9ba 100644 --- a/server/tests/organization/test_service.py +++ b/server/tests/organization/test_service.py @@ -15,7 +15,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: @pytest.mark.auth @pytest.mark.parametrize( diff --git a/server/tests/personal_access_token/test_endpoints.py b/server/tests/personal_access_token/test_endpoints.py index 018562061b..b1dbb20d60 100644 --- a/server/tests/personal_access_token/test_endpoints.py +++ b/server/tests/personal_access_token/test_endpoints.py @@ -3,7 +3,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreatePersonalAccessToken: @pytest.mark.parametrize("expires_in", [None, 3600]) @pytest.mark.auth diff --git a/server/tests/personal_access_token/test_service.py b/server/tests/personal_access_token/test_service.py index ae699d64ad..4412406e75 100644 --- a/server/tests/personal_access_token/test_service.py +++ b/server/tests/personal_access_token/test_service.py @@ -17,7 +17,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRevokeLeaked: async def test_false_positive( self, diff --git a/server/tests/pledge/test_endpoints.py b/server/tests/pledge/test_endpoints.py index 7a66d2d929..6ab059b80f 100644 --- a/server/tests/pledge/test_endpoints.py +++ b/server/tests/pledge/test_endpoints.py @@ -50,7 +50,6 @@ async def test_get_pledge( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_pledge_member_sending_org( external_organization_linked: ExternalOrganization, @@ -92,7 +91,6 @@ async def test_get_pledge_member_sending_org( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_pledge_member_sending_org_user_has_github( external_organization_linked: ExternalOrganization, @@ -138,7 +136,6 @@ async def test_get_pledge_member_sending_org_user_has_github( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_pledge_member_receiving_org( organization: Organization, @@ -181,7 +178,6 @@ async def test_get_pledge_member_receiving_org( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_pledge_not_member( organization: Organization, @@ -196,7 +192,6 @@ async def test_get_pledge_not_member( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_search_pledge( organization: Organization, @@ -223,7 +218,6 @@ async def test_search_pledge( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_search_pledge_no_member( organization: Organization, @@ -315,7 +309,6 @@ async def test_search_pledge_by_issue_id( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_search_no_params( organization: Organization, @@ -330,7 +323,6 @@ async def test_search_no_params( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_create_pay_on_completion( organization: Organization, @@ -403,7 +395,6 @@ async def test_summary( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_summary_private_repo( repository: Repository, pledge: Pledge, @@ -523,7 +514,6 @@ async def test_create_pay_on_completion_per_user_monthly_spending_limit( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_no_billing_email( organization: Organization, @@ -598,7 +588,6 @@ async def test_spending( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_spending_zero(organization: Organization, client: AsyncClient) -> None: # get spending diff --git a/server/tests/product/service/test_product.py b/server/tests/product/service/test_product.py index 832ccd75e1..4775c7e877 100644 --- a/server/tests/product/service/test_product.py +++ b/server/tests/product/service/test_product.py @@ -323,7 +323,6 @@ async def test_organization( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreate: @pytest.mark.auth async def test_user_not_existing_organization( @@ -745,7 +744,6 @@ async def test_valid_prices( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdate: @pytest.mark.auth async def test_not_writable_product( @@ -1218,7 +1216,6 @@ async def test_valid_media( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateBenefits: @pytest.mark.auth async def test_not_writable_product( diff --git a/server/tests/product/test_endpoints.py b/server/tests/product/test_endpoints.py index d0a47544ca..8cc438f9ef 100644 --- a/server/tests/product/test_endpoints.py +++ b/server/tests/product/test_endpoints.py @@ -21,7 +21,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestListProducts: async def test_anonymous( self, client: AsyncClient, organization: Organization @@ -72,7 +71,6 @@ async def test_with_benefits( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestGetProduct: async def test_anonymous(self, client: AsyncClient, product: Product) -> None: response = await client.get(f"/v1/products/{product.id}") @@ -130,7 +128,6 @@ async def test_valid_with_benefits( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateProduct: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.post( @@ -324,7 +321,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateProduct: async def test_anonymous(self, client: AsyncClient, product: Product) -> None: response = await client.patch( @@ -402,7 +398,6 @@ async def test_existing_price_with_full_schema( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateProductBenefits: async def test_anonymous(self, client: AsyncClient, product: Product) -> None: response = await client.post( diff --git a/server/tests/repository/test_endpoints.py b/server/tests/repository/test_endpoints.py index ad0e4b96e4..1726c32be7 100644 --- a/server/tests/repository/test_endpoints.py +++ b/server/tests/repository/test_endpoints.py @@ -15,7 +15,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestListRepositories: @pytest.mark.auth( AuthSubjectFixture(subject="anonymous"), diff --git a/server/tests/subscription/test_endpoints.py b/server/tests/subscription/test_endpoints.py index 47a0533178..fe55d335ad 100644 --- a/server/tests/subscription/test_endpoints.py +++ b/server/tests/subscription/test_endpoints.py @@ -9,7 +9,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListSubscriptions: async def test_anonymous( self, client: AsyncClient, organization: Organization diff --git a/server/tests/subscription/test_service.py b/server/tests/subscription/test_service.py index 0b7d38b2c1..76aa6a5c6b 100644 --- a/server/tests/subscription/test_service.py +++ b/server/tests/subscription/test_service.py @@ -897,7 +897,6 @@ async def test_organization( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts @pytest.mark.email_subscription_confirmation async def test_send_confirmation_email( mocker: MockerFixture, diff --git a/server/tests/test_openapi.py b/server/tests/test_openapi.py index 55989fcf06..afa4b54964 100644 --- a/server/tests/test_openapi.py +++ b/server/tests/test_openapi.py @@ -3,7 +3,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_openapi(client: AsyncClient) -> None: response = await client.get("/openapi.json") assert response.status_code == 200 diff --git a/server/tests/transaction/service/test_dispute.py b/server/tests/transaction/service/test_dispute.py index 8a0c716d2a..98f75111fc 100644 --- a/server/tests/transaction/service/test_dispute.py +++ b/server/tests/transaction/service/test_dispute.py @@ -474,7 +474,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateReversalBalancesForPayment: async def test_not_reversed( self, save_fixture: SaveFixture, session: AsyncSession, account: Account diff --git a/server/tests/transaction/service/test_payout.py b/server/tests/transaction/service/test_payout.py index 244c98c0ec..7f3b73e6f3 100644 --- a/server/tests/transaction/service/test_payout.py +++ b/server/tests/transaction/service/test_payout.py @@ -798,7 +798,6 @@ async def test_valid_different_currencies( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestTriggerStripePayouts: async def test_valid( self, diff --git a/server/tests/transaction/service/test_refund.py b/server/tests/transaction/service/test_refund.py index 4aacc64202..86029a4bee 100644 --- a/server/tests/transaction/service/test_refund.py +++ b/server/tests/transaction/service/test_refund.py @@ -282,7 +282,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateReversalBalancesForPayment: async def test_valid( self, save_fixture: SaveFixture, session: AsyncSession, account: Account diff --git a/server/tests/transaction/test_endpoints.py b/server/tests/transaction/test_endpoints.py index e42a35a694..cecebb0bce 100644 --- a/server/tests/transaction/test_endpoints.py +++ b/server/tests/transaction/test_endpoints.py @@ -23,7 +23,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestSearchTransactions: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get("/v1/transactions/search") @@ -48,7 +47,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestLookupTransaction: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get( @@ -95,7 +93,6 @@ async def test_transaction_payout( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestGetSummary: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.get( @@ -132,7 +129,6 @@ async def test_valid( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestCreatePayout: async def test_anonymous(self, client: AsyncClient) -> None: response = await client.post( diff --git a/server/tests/user/endpoints/test_user.py b/server/tests/user/endpoints/test_user.py index 2ad183e1ec..954bc827ed 100644 --- a/server/tests/user/endpoints/test_user.py +++ b/server/tests/user/endpoints/test_user.py @@ -7,7 +7,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth async def test_get_users_me_authed(user: User, client: AsyncClient) -> None: response = await client.get("/v1/users/me") @@ -20,7 +19,6 @@ async def test_get_users_me_authed(user: User, client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_get_users_me_no_auth(client: AsyncClient) -> None: response = await client.get( "/v1/users/me", @@ -30,7 +28,6 @@ async def test_get_users_me_no_auth(client: AsyncClient) -> None: @pytest.mark.asyncio -@pytest.mark.http_auto_expunge @pytest.mark.auth(AuthSubjectFixture(subject="user_blocked")) async def test_get_users_me_blocked(user_blocked: User, client: AsyncClient) -> None: response = await client.get("/v1/users/me") @@ -39,7 +36,6 @@ async def test_get_users_me_blocked(user_blocked: User, client: AsyncClient) -> @pytest.mark.asyncio @pytest.mark.auth -@pytest.mark.http_auto_expunge async def test_set_account( client: AsyncClient, open_collective_account: Account ) -> None: @@ -58,7 +54,6 @@ async def test_set_account( @pytest.mark.asyncio @pytest.mark.auth(AuthSubjectFixture(subject="user_blocked")) -@pytest.mark.http_auto_expunge async def test_blocked_user_set_account( client: AsyncClient, open_collective_account: Account ) -> None: diff --git a/server/tests/user/service/test_service.py b/server/tests/user/service/test_service.py index df4c240def..4db4f9bd12 100644 --- a/server/tests/user/service/test_service.py +++ b/server/tests/user/service/test_service.py @@ -13,7 +13,6 @@ @pytest.mark.asyncio -@pytest.mark.skip_db_asserts async def test_link_customers( save_fixture: SaveFixture, session: AsyncSession, diff --git a/server/tests/webhooks/test_endpoints.py b/server/tests/webhooks/test_endpoints.py index e03634de8b..a1ffe8e26b 100644 --- a/server/tests/webhooks/test_endpoints.py +++ b/server/tests/webhooks/test_endpoints.py @@ -11,7 +11,6 @@ @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListWebhookEndpoints: async def test_unauthenticated( self, @@ -56,7 +55,6 @@ async def test_authenticated( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestCreateWebhookEndpoint: @pytest.mark.auth(AuthSubjectFixture(scopes=set())) async def test_user_missing_scope(self, client: AsyncClient) -> None: @@ -115,7 +113,6 @@ async def test_organization_valid_creator_webhooks_write_scope( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestUpdateWebhookEndpoint: @pytest.mark.auth(AuthSubjectFixture(scopes=set())) async def test_user_missing_scope( @@ -170,7 +167,6 @@ async def test_organization_valid_creator_webhooks_write_scope( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestDeleteWebhookEndpoint: @pytest.mark.auth(AuthSubjectFixture(scopes=set())) async def test_user_missing_scope( @@ -225,7 +221,6 @@ async def test_organization_valid_creator_webhooks_write_scope( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge class TestListWebhookDeliveries: @pytest.mark.auth async def test_user_not_member( diff --git a/server/tests/webhooks/test_service.py b/server/tests/webhooks/test_service.py index 3df2b39edc..0daf4340cd 100644 --- a/server/tests/webhooks/test_service.py +++ b/server/tests/webhooks/test_service.py @@ -43,7 +43,6 @@ def enqueue_job_mock(mocker: MockerFixture) -> MagicMock: @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestCreateEndpoint: @pytest.mark.auth(AuthSubjectFixture(scopes={Scope.web_default})) async def test_user_no_organization_id_valid( @@ -141,7 +140,6 @@ async def test_organization_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestUpdateEndpoint: @pytest.mark.auth( AuthSubjectFixture(scopes={Scope.web_default}), @@ -252,7 +250,6 @@ async def test_organization_endpoint_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestDeleteEndpoint: @pytest.mark.auth( AuthSubjectFixture(scopes={Scope.web_default}), @@ -332,7 +329,6 @@ async def test_organization_endpoint_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestRedeliverEvent: @pytest.mark.auth( AuthSubjectFixture(scopes={Scope.web_default}), @@ -415,7 +411,6 @@ async def test_organization_endpoint_valid( @pytest.mark.asyncio -@pytest.mark.skip_db_asserts class TestOnEventSuccess: async def test_not_existing_event(self, session: AsyncSession) -> None: with pytest.raises(EventDoesNotExist): diff --git a/server/tests/webhooks/test_webhooks.py b/server/tests/webhooks/test_webhooks.py index dd45552439..3d494760cb 100644 --- a/server/tests/webhooks/test_webhooks.py +++ b/server/tests/webhooks/test_webhooks.py @@ -115,7 +115,6 @@ def in_process_enqueue_job(name, *args, **kwargs) -> None: # type: ignore # no @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_webhook_delivery( session: AsyncSession, save_fixture: SaveFixture, @@ -147,7 +146,6 @@ async def test_webhook_delivery( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_webhook_delivery_500( session: AsyncSession, save_fixture: SaveFixture, @@ -191,7 +189,6 @@ async def test_webhook_delivery_500( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_webhook_delivery_http_error( session: AsyncSession, save_fixture: SaveFixture, @@ -237,7 +234,6 @@ async def test_webhook_delivery_http_error( @pytest.mark.asyncio -@pytest.mark.http_auto_expunge async def test_webhook_standard_webhooks_compatible( session: AsyncSession, save_fixture: SaveFixture,