fix: run activity import enforcement tests without pytest-asyncio
CI container only installs pytest; use asyncio.run() for async route handlers. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ae7d0ac1d9
commit
72d101415f
|
|
@ -1,5 +1,6 @@
|
|||
"""Feature-Enforcement für Legacy Activity CSV-Import (#37)."""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
@ -8,8 +9,7 @@ from fastapi import HTTPException
|
|||
from routers.activity import import_activity_csv
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_import_activity_csv_blocks_when_limit_reached():
|
||||
def test_import_activity_csv_blocks_when_limit_reached():
|
||||
upload = AsyncMock()
|
||||
upload.read = AsyncMock(return_value=b"Workout Type,Start\n")
|
||||
|
||||
|
|
@ -23,16 +23,17 @@ async def test_import_activity_csv_blocks_when_limit_reached():
|
|||
},
|
||||
), patch("routers.activity.log_feature_usage"):
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
await import_activity_csv(
|
||||
asyncio.run(
|
||||
import_activity_csv(
|
||||
file=upload,
|
||||
x_profile_id=None,
|
||||
session={"profile_id": "profile-1"},
|
||||
)
|
||||
)
|
||||
assert exc.value.status_code == 403
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_import_activity_csv_increments_usage_per_insert(monkeypatch):
|
||||
def test_import_activity_csv_increments_usage_per_insert(monkeypatch):
|
||||
upload = AsyncMock()
|
||||
upload.read = AsyncMock(
|
||||
return_value=(
|
||||
|
|
@ -97,11 +98,13 @@ async def test_import_activity_csv_increments_usage_per_insert(monkeypatch):
|
|||
lambda _pid, feature: increments.append(feature),
|
||||
)
|
||||
|
||||
result = await import_activity_csv(
|
||||
result = asyncio.run(
|
||||
import_activity_csv(
|
||||
file=upload,
|
||||
x_profile_id=None,
|
||||
session={"profile_id": "profile-1"},
|
||||
)
|
||||
)
|
||||
|
||||
assert result["inserted"] == 1
|
||||
assert increments == ["activity_entries"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user