|
import pytest
|
|
|
|
|
|
def test_billing_module_imports():
|
|
from mywebdav.billing import (
|
|
models,
|
|
stripe_client,
|
|
usage_tracker,
|
|
invoice_generator,
|
|
scheduler,
|
|
)
|
|
|
|
assert models is not None
|
|
assert stripe_client is not None
|
|
assert usage_tracker is not None
|
|
assert invoice_generator is not None
|
|
assert scheduler is not None
|
|
|
|
|
|
def test_billing_models_exist():
|
|
from mywebdav.billing.models import (
|
|
SubscriptionPlan,
|
|
UserSubscription,
|
|
UsageRecord,
|
|
UsageAggregate,
|
|
Invoice,
|
|
InvoiceLineItem,
|
|
PricingConfig,
|
|
PaymentMethod,
|
|
BillingEvent,
|
|
)
|
|
|
|
assert SubscriptionPlan is not None
|
|
assert UserSubscription is not None
|
|
assert UsageRecord is not None
|
|
assert UsageAggregate is not None
|
|
assert Invoice is not None
|
|
assert InvoiceLineItem is not None
|
|
assert PricingConfig is not None
|
|
assert PaymentMethod is not None
|
|
assert BillingEvent is not None
|
|
|
|
|
|
def test_stripe_client_exists():
|
|
from mywebdav.billing.stripe_client import StripeClient
|
|
|
|
assert StripeClient is not None
|
|
assert hasattr(StripeClient, "create_customer")
|
|
assert hasattr(StripeClient, "create_invoice")
|
|
assert hasattr(StripeClient, "finalize_invoice")
|
|
|
|
|
|
def test_usage_tracker_exists():
|
|
from mywebdav.billing.usage_tracker import UsageTracker
|
|
|
|
assert UsageTracker is not None
|
|
assert hasattr(UsageTracker, "track_storage")
|
|
assert hasattr(UsageTracker, "track_bandwidth")
|
|
assert hasattr(UsageTracker, "aggregate_daily_usage")
|
|
assert hasattr(UsageTracker, "get_current_storage")
|
|
assert hasattr(UsageTracker, "get_monthly_usage")
|
|
|
|
|
|
def test_invoice_generator_exists():
|
|
from mywebdav.billing.invoice_generator import InvoiceGenerator
|
|
|
|
assert InvoiceGenerator is not None
|
|
assert hasattr(InvoiceGenerator, "generate_monthly_invoice")
|
|
assert hasattr(InvoiceGenerator, "finalize_invoice")
|
|
assert hasattr(InvoiceGenerator, "mark_invoice_paid")
|
|
|
|
|
|
def test_scheduler_exists():
|
|
from mywebdav.billing.scheduler import scheduler, start_scheduler, stop_scheduler
|
|
|
|
assert scheduler is not None
|
|
assert callable(start_scheduler)
|
|
assert callable(stop_scheduler)
|
|
|
|
|
|
def test_routers_exist():
|
|
from mywebdav.routers import billing, admin_billing
|
|
|
|
assert billing is not None
|
|
assert admin_billing is not None
|
|
assert hasattr(billing, "router")
|
|
assert hasattr(admin_billing, "router")
|
|
|
|
|
|
def test_middleware_exists():
|
|
from mywebdav.middleware.usage_tracking import UsageTrackingMiddleware
|
|
|
|
assert UsageTrackingMiddleware is not None
|
|
|
|
|
|
def test_settings_updated():
|
|
from mywebdav.settings import settings
|
|
|
|
assert hasattr(settings, "STRIPE_SECRET_KEY")
|
|
assert hasattr(settings, "STRIPE_PUBLISHABLE_KEY")
|
|
assert hasattr(settings, "STRIPE_WEBHOOK_SECRET")
|
|
assert hasattr(settings, "BILLING_ENABLED")
|
|
|
|
|
|
def test_main_includes_billing():
|
|
from mywebdav.main import app
|
|
|
|
routes = [route.path for route in app.routes]
|
|
billing_routes = [r for r in routes if "/billing" in r]
|
|
assert len(billing_routes) > 0
|