perf(douyu): 限制任务并发并释放长事务连接
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from starlette.requests import ClientDisconnect
|
||||
|
||||
from web.backend.models import (
|
||||
Account,
|
||||
@@ -14,7 +16,10 @@ from web.backend.models import (
|
||||
PlatformFulfillmentTask,
|
||||
User,
|
||||
)
|
||||
from web.backend.routers.platform_fulfillment_integration import require_integration_key
|
||||
from web.backend.routers.platform_fulfillment_integration import (
|
||||
require_integration_key,
|
||||
sync_order_event,
|
||||
)
|
||||
from web.backend.services.platform_fulfillment import service
|
||||
|
||||
|
||||
@@ -31,6 +36,32 @@ def test_integration_key_is_required(monkeypatch):
|
||||
assert invalid.value.status_code == 401
|
||||
|
||||
|
||||
def test_webhook_client_disconnect_is_not_an_application_error(monkeypatch):
|
||||
monkeypatch.setenv("PLATFORM_FULFILLMENT_INTEGRATION_KEY", "secret")
|
||||
|
||||
class DisconnectingRequest:
|
||||
async def body(self):
|
||||
raise ClientDisconnect()
|
||||
|
||||
result = asyncio.run(
|
||||
sync_order_event(
|
||||
request=DisconnectingRequest(),
|
||||
db=object(),
|
||||
x_integration_key="secret",
|
||||
x_integration_event_id="",
|
||||
x_integration_timestamp="",
|
||||
x_integration_signature="",
|
||||
)
|
||||
)
|
||||
|
||||
assert result == {
|
||||
"fetched": 0,
|
||||
"created": 0,
|
||||
"updated": 0,
|
||||
"disconnected": True,
|
||||
}
|
||||
|
||||
|
||||
def test_customer_binding_out_hides_internal_account_data(db):
|
||||
user = User(
|
||||
username="integration-actor",
|
||||
|
||||
Reference in New Issue
Block a user