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.

60 lines
2.3 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. self.assertNotContains(r, "jumbotron")
  9. # A subscription object should have NOT been created
  10. self.assertFalse(Subscription.objects.exists())
  11. def test_authenticated(self):
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.get("/pricing/")
  14. self.assertContains(r, "Unlimited Team Members", status_code=200)
  15. self.assertContains(r, "jumbotron")
  16. # A subscription object still should have NOT been created
  17. self.assertFalse(Subscription.objects.exists())
  18. def test_authenticated_for_project(self):
  19. self.client.login(username="[email protected]", password="password")
  20. r = self.client.get("/projects/%s/pricing/" % self.project.code)
  21. self.assertContains(r, "Unlimited Team Members", status_code=200)
  22. self.assertContains(r, "jumbotron")
  23. @override_settings(USE_PAYMENTS=True)
  24. def test_pricing_is_visible_for_all(self):
  25. for email in ("[email protected]", "[email protected]"):
  26. self.client.login(username=email, password="password")
  27. r = self.client.get("/docs/")
  28. self.assertContains(r, "Pricing")
  29. def test_it_offers_to_switch(self):
  30. self.client.login(username="[email protected]", password="password")
  31. r = self.client.get("/projects/%s/pricing/" % self.project.code)
  32. self.assertContains(r, "To manage billing for this project")
  33. def test_it_shows_active_plan(self):
  34. self.sub = Subscription(user=self.alice)
  35. self.sub.subscription_id = "test-id"
  36. self.sub.plan_id = "P20"
  37. self.sub.plan_name = "Business ($20 / month)"
  38. self.sub.save()
  39. self.client.login(username="[email protected]", password="password")
  40. r = self.client.get("/pricing/")
  41. self.assertContains(r, "Business ($20 / month)", status_code=200)
  42. r = self.client.get("/projects/%s/pricing/" % self.project.code)
  43. self.assertContains(r, "Business ($20 / month)", status_code=200)