question packs instead of monthly/yearly plans; hearts are real
- packs (20 / 60 / 150 questions for 45,000 / 119,000 / 259,000 toman) never expire and give 7 / 30 / 60 days of unlimited hearts; old subscription plans stay for existing subscribers but are no longer on sale - credit ledger (subscription.QuestionCredit): +N per paid pack (once per order), -1 per tutor question that reaches the API; the free daily questions are spent first; questions stopped by the server filter, cached answers and failed answers cost nothing - unlimited hearts from packs live in HeartsPass, so buying a pack never rewrites a running subscription - Message.charge records how each question was paid; GET /api/ai/quota and the ask responses report free-left-today and credits - HEARTS_ENFORCED now defaults to on: zero hearts stops answering until refill or a pack Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -571,18 +571,16 @@ class YearlyPlanSeedTests(TestCase):
|
||||
self.assertEqual((plan.price, plan.ai_daily_quota), (450_000, 9))
|
||||
self.assertEqual(Plan.objects.filter(duration_days=30).count(), 1)
|
||||
|
||||
def test_plans_api_reports_each_quota_and_the_free_one(self):
|
||||
def test_only_question_packs_are_on_sale(self):
|
||||
from django.core.cache import cache
|
||||
cache.clear()
|
||||
data = self.client.get('/api/subscription/plans').json()
|
||||
self.assertEqual({p['kind'] for p in data['plans']}, {'pack'})
|
||||
self.assertEqual([p['questionCredits'] for p in data['plans']], [20, 60, 150])
|
||||
self.assertEqual([p['heartsDays'] for p in data['plans']], [7, 30, 60])
|
||||
self.assertEqual(data['freeAiDailyQuota'], 3)
|
||||
self.assertEqual({p['aiDailyQuota'] for p in data['plans']}, {10})
|
||||
|
||||
def test_it_is_served_to_the_app(self):
|
||||
from django.core.cache import cache
|
||||
cache.clear()
|
||||
titles = [p['title'] for p in self.client.get('/api/subscription/plans').json()['plans']]
|
||||
self.assertIn('اشتراک یکساله', titles)
|
||||
# پلنهای اشتراکی پاک نشدهاند؛ فقط فروخته نمیشوند.
|
||||
self.assertFalse(Plan.objects.get(title='اشتراک یکساله').on_sale)
|
||||
|
||||
def test_it_never_overwrites_existing_plans(self):
|
||||
import importlib
|
||||
|
||||
Reference in New Issue
Block a user