Files
adaptive-pricing/projects/coulomb-pricing/tests/test_pricing_model_schema.py

36 lines
1.3 KiB
Python

from __future__ import annotations
from decimal import Decimal
from pathlib import Path
from adaptive_pricing_core.pricing_models import validate_pricing_catalog
from observatory.load import load_pricing_models
DATA_DIR = Path(__file__).resolve().parent.parent / "data"
def test_coulomb_pricing_catalog_validates() -> None:
models = load_pricing_models(DATA_DIR)
assert validate_pricing_catalog(models) == {}
def test_hybrid_model_preserves_usage_component_and_tuning_metadata() -> None:
models = load_pricing_models(DATA_DIR)
model = next(item for item in models if item.id == "membership-plus-overage")
usage_component = next(component for component in model.charge_components if component.kind == "usage")
assert usage_component.meter == "openrouter_tokens"
assert usage_component.included_units == Decimal("100000")
assert usage_component.unit_price == Decimal("0.002")
assert any(parameter.parameter_class == "customer_tunable" for parameter in model.tunable_parameters)
def test_flat_model_still_exposes_access_fee_compatibility_fields() -> None:
models = load_pricing_models(DATA_DIR)
model = next(item for item in models if item.id == "flat-899-eur-monthly")
assert model.access_fee_amount == Decimal("8.99")
assert model.access_fee_cadence == "monthly"
assert len(model.charge_components) == 1