Upload folder using huggingface_hub
Browse files- tests/test_subscription.py +80 -1
tests/test_subscription.py
CHANGED
|
@@ -13,7 +13,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
| 13 |
|
| 14 |
from splitbit_llm.subscription import (
|
| 15 |
SubscriptionManager, MONTHLY_PRICE, SOULMATE_API_URL,
|
| 16 |
-
FOUNDER_EMAIL, ACCEPTED_TOKENS, NETWORK,
|
| 17 |
)
|
| 18 |
|
| 19 |
|
|
@@ -341,6 +341,77 @@ def test_soulmate_config():
|
|
| 341 |
print(f" Network: {NETWORK}")
|
| 342 |
|
| 343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
if __name__ == "__main__":
|
| 345 |
print("Running subscription manager tests...")
|
| 346 |
test_no_subscription_blocks_access()
|
|
@@ -375,4 +446,12 @@ if __name__ == "__main__":
|
|
| 375 |
print(" β test_subscribe_with_deposit")
|
| 376 |
test_soulmate_config()
|
| 377 |
print(" β test_soulmate_config")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
print("\nAll subscription tests passed!")
|
|
|
|
| 13 |
|
| 14 |
from splitbit_llm.subscription import (
|
| 15 |
SubscriptionManager, MONTHLY_PRICE, SOULMATE_API_URL,
|
| 16 |
+
FOUNDER_EMAIL, FOUNDER_PASSWORD, ACCEPTED_TOKENS, NETWORK,
|
| 17 |
)
|
| 18 |
|
| 19 |
|
|
|
|
| 341 |
print(f" Network: {NETWORK}")
|
| 342 |
|
| 343 |
|
| 344 |
+
def test_founder_unlock_correct_password():
|
| 345 |
+
"""Test founder unlock with correct password grants free forever access."""
|
| 346 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 347 |
+
sub = SubscriptionManager(data_dir=tmpdir)
|
| 348 |
+
|
| 349 |
+
# No access before unlock
|
| 350 |
+
access = sub.check_access()
|
| 351 |
+
assert not access["has_access"]
|
| 352 |
+
|
| 353 |
+
# Unlock with correct password
|
| 354 |
+
result = sub.founder_unlock(FOUNDER_PASSWORD)
|
| 355 |
+
assert result["success"]
|
| 356 |
+
assert result["status"] == "founder"
|
| 357 |
+
print(f" Unlock: {result['message']}")
|
| 358 |
+
|
| 359 |
+
# Now has access β forever
|
| 360 |
+
access = sub.check_access()
|
| 361 |
+
assert access["has_access"]
|
| 362 |
+
assert access["status"] == "founder"
|
| 363 |
+
assert access["days_remaining"] == -1 # forever
|
| 364 |
+
print(f" Access: {access['status']} β {access['message']}")
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
def test_founder_unlock_wrong_password():
|
| 368 |
+
"""Test founder unlock with wrong password fails."""
|
| 369 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 370 |
+
sub = SubscriptionManager(data_dir=tmpdir)
|
| 371 |
+
|
| 372 |
+
result = sub.founder_unlock("wrongpassword123")
|
| 373 |
+
assert not result["success"]
|
| 374 |
+
assert "Invalid" in result["error"]
|
| 375 |
+
print(f" Wrong password: {result['error']}")
|
| 376 |
+
|
| 377 |
+
# Still no access
|
| 378 |
+
access = sub.check_access()
|
| 379 |
+
assert not access["has_access"]
|
| 380 |
+
print(f" Access after wrong password: blocked")
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
def test_founder_unlock_persists():
|
| 384 |
+
"""Test founder unlock persists across restarts."""
|
| 385 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 386 |
+
sub1 = SubscriptionManager(data_dir=tmpdir)
|
| 387 |
+
sub1.founder_unlock(FOUNDER_PASSWORD)
|
| 388 |
+
|
| 389 |
+
# New instance should load founder status
|
| 390 |
+
sub2 = SubscriptionManager(data_dir=tmpdir)
|
| 391 |
+
access = sub2.check_access()
|
| 392 |
+
assert access["has_access"]
|
| 393 |
+
assert access["status"] == "founder"
|
| 394 |
+
print(f" Persisted: status={access['status']}, forever={access['days_remaining'] == -1}")
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def test_founder_unlock_bypasses_payment():
|
| 398 |
+
"""Test founder doesn't need to pay β access is free forever."""
|
| 399 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 400 |
+
sub = SubscriptionManager(data_dir=tmpdir)
|
| 401 |
+
sub.founder_unlock(FOUNDER_PASSWORD)
|
| 402 |
+
|
| 403 |
+
# Founder should have no payment history
|
| 404 |
+
stats = sub.get_stats()
|
| 405 |
+
assert stats["months_subscribed"] == 0
|
| 406 |
+
assert stats["total_paid"] == 0.0
|
| 407 |
+
print(f" Founder payments: ${stats['total_paid']:.2f} (free)")
|
| 408 |
+
|
| 409 |
+
# But has full access
|
| 410 |
+
access = sub.check_access()
|
| 411 |
+
assert access["has_access"]
|
| 412 |
+
print(f" Founder access: free forever")
|
| 413 |
+
|
| 414 |
+
|
| 415 |
if __name__ == "__main__":
|
| 416 |
print("Running subscription manager tests...")
|
| 417 |
test_no_subscription_blocks_access()
|
|
|
|
| 446 |
print(" β test_subscribe_with_deposit")
|
| 447 |
test_soulmate_config()
|
| 448 |
print(" β test_soulmate_config")
|
| 449 |
+
test_founder_unlock_correct_password()
|
| 450 |
+
print(" β test_founder_unlock_correct_password")
|
| 451 |
+
test_founder_unlock_wrong_password()
|
| 452 |
+
print(" β test_founder_unlock_wrong_password")
|
| 453 |
+
test_founder_unlock_persists()
|
| 454 |
+
print(" β test_founder_unlock_persists")
|
| 455 |
+
test_founder_unlock_bypasses_payment()
|
| 456 |
+
print(" β test_founder_unlock_bypasses_payment")
|
| 457 |
print("\nAll subscription tests passed!")
|