Skip to content

Commit 4c9ee1a

Browse files
committed
fixes
1 parent 5271c64 commit 4c9ee1a

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

backend/app/db/repositories/execution_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def get_executions(
143143
created_at=doc.get("created_at", datetime.now(timezone.utc)),
144144
updated_at=doc.get("updated_at", datetime.now(timezone.utc)),
145145
resource_usage=(
146-
ResourceUsageDomain.from_dict(dict(resource_usage_data))
146+
ResourceUsageDomain.from_dict(resource_usage_data)
147147
if resource_usage_data is not None
148148
else None
149149
),

backend/tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def create_test_app():
126126

127127

128128
# ===== App without lifespan for tests =====
129-
@pytest_asyncio.fixture(scope="function")
129+
@pytest_asyncio.fixture(scope="session")
130130
async def app():
131-
"""Create FastAPI app for the function without starting lifespan."""
131+
"""Create FastAPI app once per session/worker to avoid Pydantic schema crashes."""
132132
application = create_test_app()
133133

134134
yield application
@@ -138,7 +138,7 @@ async def app():
138138
await container.close()
139139

140140

141-
@pytest_asyncio.fixture(scope="function")
141+
@pytest_asyncio.fixture(scope="session")
142142
async def app_container(app): # type: ignore[valid-type]
143143
"""Expose the Dishka container attached to the app."""
144144
container: AsyncContainer = app.state.dishka_container # type: ignore[attr-defined]

backend/tests/fixtures/real_services.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -311,33 +311,37 @@ async def ensure_services_running():
311311
import subprocess
312312

313313
# Check MongoDB
314-
try:
314+
async def check_mongo() -> None:
315315
client = AsyncMongoClient(
316316
"mongodb://root:rootpassword@localhost:27017",
317317
serverSelectionTimeoutMS=5000
318318
)
319-
await client.admin.command("ping")
320-
await client.close()
319+
try:
320+
await client.admin.command("ping")
321+
finally:
322+
await client.close()
323+
324+
try:
325+
await check_mongo()
321326
except Exception:
322327
print("Starting MongoDB...")
323328
subprocess.run(["docker-compose", "up", "-d", "mongo"], check=False)
324-
await wait_for_service(
325-
lambda: AsyncMongoClient("mongodb://root:rootpassword@localhost:27017").admin.command("ping"),
326-
service_name="MongoDB"
327-
)
328-
329+
await wait_for_service(check_mongo, service_name="MongoDB")
330+
329331
# Check Redis
330-
try:
332+
async def check_redis() -> None:
331333
r = redis.Redis(host="localhost", port=6379, socket_connect_timeout=5)
332-
await r.execute_command("PING")
333-
await r.aclose()
334+
try:
335+
await r.execute_command("PING")
336+
finally:
337+
await r.aclose()
338+
339+
try:
340+
await check_redis()
334341
except Exception:
335342
print("Starting Redis...")
336343
subprocess.run(["docker-compose", "up", "-d", "redis"], check=False)
337-
await wait_for_service(
338-
lambda: redis.Redis(host="localhost", port=6379).execute_command("PING"),
339-
service_name="Redis"
340-
)
344+
await wait_for_service(check_redis, service_name="Redis")
341345

342346
# Kafka is optional - don't fail if not available
343347
try:

backend/tests/integration/db/schema/test_schema_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ async def test_apply_all_idempotent_and_creates_indexes(db) -> None: # type: ig
2828

2929
# Verify some expected indexes exist
3030
async def idx_names(coll: str) -> set[str]:
31-
lst = await db[coll].list_indexes().to_list(length=None)
31+
cursor = await db[coll].list_indexes()
32+
lst = await cursor.to_list(length=None)
3233
return {i.get("name", "") for i in lst}
3334

3435
# events

backend/tests/integration/services/saved_script/test_saved_script_service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
pytestmark = [pytest.mark.integration, pytest.mark.mongodb]
88

9-
pytestmark = pytest.mark.integration
10-
119

1210
def _create_payload() -> DomainSavedScriptCreate:
1311
return DomainSavedScriptCreate(name="n", description=None, script="print(1)")

0 commit comments

Comments
 (0)