Files
adaptive-pricing/projects/coulomb-pricing/tests/test_economics.py
tegwick 8f42220d81 Adapt economics dashboard to sole-member zero-cost reality
Update membership, revenue, and cost registries to one active member with
no running costs. Refresh dashboard report and tests for €8.99 revenue and
100% gross margin.
2026-06-22 01:41:59 +02:00

55 lines
1.8 KiB
Python

from __future__ import annotations
from decimal import Decimal
from pathlib import Path
from observatory.economics import active_members, build_snapshot, monthly_cost_total
from observatory.load import (
load_costs,
load_membership,
load_pricing_models,
load_product,
load_revenue,
)
DATA_DIR = Path(__file__).resolve().parent.parent / "data"
def test_active_members_counts_only_active_status() -> None:
members = load_membership(DATA_DIR)
assert active_members(members) == 1
def test_build_snapshot_reflects_sole_member_and_zero_costs() -> None:
product = load_product(DATA_DIR)
models = load_pricing_models(DATA_DIR)
members = load_membership(DATA_DIR)
revenue = load_revenue(DATA_DIR)
_, costs, fx_rates = load_costs(DATA_DIR)
snapshot = build_snapshot("2026-06", product, models, members, revenue, costs, fx_rates)
assert snapshot.active_members == 1
assert snapshot.monthly_revenue == Decimal("8.99")
assert snapshot.revenue_source == "manual"
assert snapshot.pricing_model_count == 3
assert snapshot.monthly_cost == Decimal("0.00")
assert snapshot.cost_per_member == Decimal("0.00")
assert snapshot.gross_margin == Decimal("8.99")
assert snapshot.gross_margin_pct == Decimal("100.0")
def test_monthly_cost_is_zero_with_empty_registry() -> None:
_, costs, fx_rates = load_costs(DATA_DIR)
total = monthly_cost_total(costs, fx_rates, Decimal("8.99"), 1)
assert total == Decimal("0.00")
def test_dashboard_module_renders_markdown() -> None:
from observatory.dashboard import generate_dashboard
report = generate_dashboard(DATA_DIR, "2026-06")
assert "# Economics Dashboard v1" in report
assert "Pricing Model Registry" in report
assert "flat-899-eur-monthly" in report
assert "Active members | 1" in report