"""探针：cost 分析端点行为"""
from fastapi.testclient import TestClient
from sqlalchemy.orm import Session
from tests.conftest import create_test_user, get_token_for_user, auth_header


class TestProbeCost:
    BASE = "/api/cma/cost"

    def test_probe_overview(self, client: TestClient, db: Session):
        create_test_user(db)
        token = get_token_for_user(client)
        r = client.get(f"{self.BASE}/overview?period=2026-06", headers=auth_header(token))
        print("OVERVIEW", r.status_code, r.text[:150])

    def test_probe_variance(self, client: TestClient, db: Session):
        create_test_user(db)
        token = get_token_for_user(client)
        r = client.get(f"{self.BASE}/variance?product_code=PROD_A&period=2026-06", headers=auth_header(token))
        print("VARIANCE", r.status_code, r.text[:200])

    def test_probe_breakdown(self, client: TestClient, db: Session):
        create_test_user(db)
        token = get_token_for_user(client)
        r = client.get(f"{self.BASE}/breakdown?product_code=PROD_A&period=2026-06", headers=auth_header(token))
        print("BREAKDOWN", r.status_code, r.text[:200])

    def test_probe_comparison(self, client: TestClient, db: Session):
        create_test_user(db)
        token = get_token_for_user(client)
        r = client.get(f"{self.BASE}/comparison?entity=hanke", headers=auth_header(token))
        print("COMPARISON", r.status_code, r.text[:120])

    def test_probe_dashboard(self, client: TestClient, db: Session):
        create_test_user(db)
        token = get_token_for_user(client)
        r = client.get(f"{self.BASE}/dashboard?period=2026-06", headers=auth_header(token))
        print("DASHBOARD", r.status_code, r.text[:300])
