Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /GRID-INTELLIGENCE_GRID /tests /billing /test_billing.py
| """Test script for billing service.""" | |
| import sys | |
| sys.path.insert(0, "src") | |
| import pytest | |
| import pytest_asyncio | |
| from src.grid.billing import BillingService, CostTier | |
| from src.grid.infrastructure.database import DatabaseManager | |
| async def billing_setup(tmp_path): | |
| db_path = str(tmp_path / "billing_test.db") | |
| db = DatabaseManager(db_path) | |
| await db.initialize_schema() | |
| billing = BillingService(db) | |
| yield billing, db | |
| await db.close() | |
| async def test_billing_tier_management(billing_setup): | |
| billing, db = billing_setup | |
| user_id = "user_123" | |
| # Default tier should be FREE | |
| tier = await billing.get_user_tier(user_id) | |
| assert tier == CostTier.FREE | |
| # Set to STARTER | |
| await billing.set_user_tier(user_id, CostTier.STARTER) | |
| tier = await billing.get_user_tier(user_id) | |
| assert tier == CostTier.STARTER | |
| async def test_billing_usage_summary(billing_setup): | |
| billing, db = billing_setup | |
| user_id = "user_456" | |
| await billing.set_user_tier(user_id, CostTier.STARTER) | |
| summary = await billing.get_usage_summary(user_id) | |
| assert summary["tier"] == "starter" | |
| assert "current_bill_cents" in summary | |
Xet Storage Details
- Size:
- 1.23 kB
- Xet hash:
- 572d9f2843aba54c8901a1ce27ca4d1bb954cd1247dc687a4d8d8242dd31a972
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.