shinkan-jinkendo/backend/tests/test_club_feature_logger.py
Lars 7411543a97
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 46s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 40s
Test Suite / playwright-tests (push) Successful in 1m14s
Enhance Planning AI with Roadmap-First Architecture and New Features
- Introduced a roadmap-first approach for the planning AI, allowing for a structured progression graph that aligns with the overall project roadmap.
- Updated the `ExerciseProgressionPathBuilder` to include a roadmap preview and improved handling of focus areas and skills catalog.
- Added functionality to strip off-topic steps from the exercise path, enhancing the relevance of generated paths.
- Implemented a new method to build detailed goal texts for AI-generated exercises, improving clarity and context.
- Incremented application version to 0.8.205 and updated database schema version to 20260606086 to reflect these changes.
2026-06-08 08:23:33 +02:00

66 lines
2.0 KiB
Python

"""Tests für club_feature_logger und probe (ohne DB)."""
import json
from club_feature_logger import feature_usage_logger, log_club_feature_usage
from club_features import club_feature_enforcement_enabled, probe_club_feature_access
def test_log_club_feature_usage_json(monkeypatch):
captured = []
monkeypatch.setattr(feature_usage_logger, "info", lambda msg: captured.append(msg))
access = {
"allowed": False,
"limit": 0,
"used": 3,
"remaining": 0,
"reason": "feature_disabled",
"plan_id": "free",
}
log_club_feature_usage(
club_id=12,
profile_id=7,
feature_id="ai_calls",
action="suggest",
access=access,
endpoint="POST /exercises/ai/suggest",
)
assert captured
payload = json.loads(captured[-1])
assert payload["club_id"] == 12
assert payload["profile_id"] == 7
assert payload["feature"] == "ai_calls"
assert payload["allowed"] is False
assert payload["plan_id"] == "free"
assert payload["phase"] == "probe"
def test_probe_no_club_context_logs_without_db(monkeypatch):
# CI/Deploy kann CLUB_FEATURE_ENFORCE=1 setzen — Test prüft Probe-Modus (kein Hard-Block).
monkeypatch.delenv("CLUB_FEATURE_ENFORCE", raising=False)
logged = []
def _capture(**kwargs):
logged.append(kwargs)
monkeypatch.setattr("club_feature_logger.log_club_feature_usage", _capture)
access = probe_club_feature_access(
feature_id="ai_calls",
action="suggest",
club_id=None,
profile_id=1,
endpoint="test",
)
assert access["reason"] == "no_club_context"
assert access["allowed"] is True
assert len(logged) == 1
assert logged[0]["club_id"] is None
def test_club_feature_enforcement_default_off(monkeypatch):
monkeypatch.delenv("CLUB_FEATURE_ENFORCE", raising=False)
assert club_feature_enforcement_enabled() is False
monkeypatch.setenv("CLUB_FEATURE_ENFORCE", "1")
assert club_feature_enforcement_enabled() is True