fix: CI test failure — skip WeasyPrint tests when native libs unavailable

- Add requires_weasyprint marker to TestGenerateBusinessPlan and TestWorkerHandler
  (these need libgobject/pango/cairo which CI python:3.12-slim lacks)
- Fix export route tests: use opaque tokens instead of integer IDs
- Replace deprecated datetime.utcnow() with datetime.now(UTC)
- Add missing jsonify/Response imports to admin routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-22 23:07:04 +01:00
parent 76695f3902
commit 0521e89d7c
3 changed files with 66 additions and 40 deletions

View File

@@ -6,16 +6,17 @@ import hmac
import sqlite3
import tempfile
import time
from datetime import datetime
from datetime import UTC, datetime
from pathlib import Path
from unittest.mock import AsyncMock, patch
import aiosqlite
import pytest
from padelnomics import core
from padelnomics.app import create_app
from padelnomics.migrations.migrate import migrate
from padelnomics import core
_SCHEMA_CACHE = None
@@ -87,7 +88,7 @@ async def client(app):
@pytest.fixture
async def test_user(db):
"""Create a test user, return dict with id/email/name."""
now = datetime.utcnow().isoformat()
now = datetime.now(UTC).isoformat()
async with db.execute(
"INSERT INTO users (email, name, created_at) VALUES (?, ?, ?)",
("test@example.com", "Test User", now),
@@ -119,7 +120,7 @@ def create_subscription(db):
provider_subscription_id: str = "sub_test456",
current_period_end: str = "2025-03-01T00:00:00Z",
) -> int:
now = datetime.utcnow().isoformat()
now = datetime.now(UTC).isoformat()
# Create billing_customers record if provider_customer_id given
if provider_customer_id:
await db.execute(
@@ -147,9 +148,10 @@ def create_subscription(db):
async def scenario(db, test_user):
"""User scenario with valid planner state for PDF generation."""
import json
from padelnomics.planner.calculator import validate_state
state = validate_state({"dblCourts": 4, "sglCourts": 2})
now = datetime.utcnow().isoformat()
now = datetime.now(UTC).isoformat()
async with db.execute(
"""INSERT INTO scenarios (user_id, name, state_json, created_at)
VALUES (?, 'Test Scenario', ?, ?)""",