"""Offline checks for the OpenTelemetry demo; no network."""
import unittest
from decimal import Decimal
from otel_agent_trace import Usage, Rates, estimated_charge, demo_trace

class TestDemo(unittest.TestCase):
    def test_cost(self):
        rates = Rates(Decimal("2"), Decimal(".5"), Decimal("8"))
        self.assertEqual(estimated_charge(Usage(120,40,30),rates),Decimal(".000420"))
    def test_invalid(self):
        with self.assertRaises(ValueError):
            Usage(10,11,2)
    def test_spans(self):
        spans, charge = demo_trace()
        self.assertEqual(len(spans),3)
        self.assertEqual(sum(bool(s.parent) for s in spans),2)
        self.assertEqual(charge,Decimal(".000420"))
        self.assertTrue(all("gen_ai.input.messages" not in s.attributes for s in spans))

if __name__ == "__main__":
    unittest.main()
