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.

21 lines
719 B

  1. from unittest.mock import patch
  2. from hc.payments.models import Subscription
  3. from hc.test import BaseTestCase
  4. class GetClientTokenTestCase(BaseTestCase):
  5. @patch("hc.payments.models.braintree")
  6. def test_it_works(self, mock_braintree):
  7. sub = Subscription(user=self.alice)
  8. sub.customer_id = "fake-customer-id"
  9. sub.save()
  10. mock_braintree.ClientToken.generate.return_value = "test-token"
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.get("/pricing/token/")
  13. self.assertContains(r, "test-token", status_code=200)
  14. # A subscription object should have been created
  15. assert Subscription.objects.count() == 1