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.

40 lines
1.3 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from mock import Mock, patch
  2. from hc.payments.models import Subscription
  3. from hc.test import BaseTestCase
  4. class InvoiceTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(InvoiceTestCase, self).setUp()
  7. self.sub = Subscription(user=self.alice)
  8. self.sub.subscription_id = "test-id"
  9. self.sub.customer_id = "test-customer-id"
  10. self.sub.save()
  11. @patch("hc.payments.views.braintree")
  12. def test_it_works(self, mock_braintree):
  13. tx = Mock()
  14. tx.id = "abc123"
  15. tx.customer_details.id = "test-customer-id"
  16. tx.created_at = None
  17. mock_braintree.Transaction.find.return_value = tx
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.get("/invoice/abc123/")
  20. self.assertContains(r, "ABC123") # tx.id in uppercase
  21. @patch("hc.payments.views.braintree")
  22. def test_it_checks_customer_id(self, mock_braintree):
  23. tx = Mock()
  24. tx.id = "abc123"
  25. tx.customer_details.id = "test-another-customer-id"
  26. tx.created_at = None
  27. mock_braintree.Transaction.find.return_value = tx
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.get("/invoice/abc123/")
  30. self.assertEqual(r.status_code, 403)