generated from coulomb/repo-seed
Implement SAND-WP-0006: SaaS payments, routing, and ext.saas-stub
Add credits store, metering on create/destroy, extension routing resolver, metered SaaS stub extension, burst/saas profiles, credits CLI, docs, and tests.
This commit is contained in:
30
tests/test_saas_stub.py
Normal file
30
tests/test_saas_stub.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""SaaS stub extension tests."""
|
||||
|
||||
from sandboxer.extensions.saas_stub import SaaSStubExtension
|
||||
from sandboxer.models import Profile
|
||||
|
||||
|
||||
def _profile() -> Profile:
|
||||
return Profile.model_validate(
|
||||
{"id": "profile.saas-stub", "version": "1.0.0", "extension": "ext.saas-stub"}
|
||||
)
|
||||
|
||||
|
||||
def test_estimate_and_meter() -> None:
|
||||
ext = SaaSStubExtension({"rate_usd_per_hour": 1.0, "session_fee_usd": 0.05})
|
||||
quote = ext.estimate_cost(_profile(), {}, duration_s=3600)
|
||||
assert quote is not None
|
||||
assert quote.estimated_usd == 1.05
|
||||
|
||||
handle = ext.provision(_profile(), {}, "saas")
|
||||
actual = ext.meter_actual(handle, duration_s=1800)
|
||||
assert actual == 0.55
|
||||
|
||||
|
||||
def test_provision_wait_teardown() -> None:
|
||||
ext = SaaSStubExtension()
|
||||
handle = ext.provision(_profile(), {}, "saas-stub")
|
||||
reach = ext.wait_ready(handle)
|
||||
assert reach["endpoint"].startswith("https://stub.sandboxer.local/")
|
||||
report = ext.teardown(handle)
|
||||
assert report["provider_removed"] == "true"
|
||||
Reference in New Issue
Block a user