You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB

9 years ago
9 years ago
9 years ago
  1. from django.test import override_settings
  2. from hc.payments.models import Subscription
  3. from hc.test import BaseTestCase
  4. class PricingTestCase(BaseTestCase):
  5. def test_anonymous(self):
  6. r = self.client.get("/pricing/")
  7. self.assertContains(r, "Unlimited Team Members", status_code=200)
  8. # A subscription object should have NOT been created
  9. assert Subscription.objects.count() == 0
  10. def test_authenticated(self):
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.get("/pricing/")
  13. self.assertContains(r, "Unlimited Team Members", status_code=200)
  14. # A subscription object still should have NOT been created
  15. assert Subscription.objects.count() == 0
  16. @override_settings(USE_PAYMENTS=True)
  17. def test_pricing_is_visible_for_all(self):
  18. for email in ("[email protected]", "[email protected]"):
  19. self.client.login(username=email, password="password")
  20. r = self.client.get("/docs/")
  21. self.assertContains(r, "Pricing")
  22. def test_it_offers_to_switch(self):
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.get("/pricing/")
  25. self.assertContains(r, "To manage this team")
  26. def test_it_shows_active_plan(self):
  27. self.sub = Subscription(user=self.alice)
  28. self.sub.subscription_id = "test-id"
  29. self.sub.plan_id = "P20"
  30. self.sub.plan_name = "Standard ($20 / month)"
  31. self.sub.save()
  32. self.client.login(username="[email protected]", password="password")
  33. r = self.client.get("/pricing/")
  34. self.assertContains(r, "Standard ($20 / month)", status_code=200)