healthchecks/hc/payments/tests/test_payment_method.py
2020-03-01 22:30:12 +02:00

31 lines
1.1 KiB
Python

from unittest.mock import patch
from hc.payments.models import Subscription
from hc.test import BaseTestCase
class UpdatePaymentMethodTestCase(BaseTestCase):
@patch("hc.payments.models.braintree")
def test_it_retrieves_paypal(self, mock):
mock.paypal_account.PayPalAccount = dict
mock.credit_card.CreditCard = list
mock.PaymentMethod.find.return_value = {"email": "foo@example.org"}
Subscription.objects.create(user=self.alice)
self.client.login(username="alice@example.org", password="password")
r = self.client.get("/accounts/profile/billing/payment_method/")
self.assertContains(r, "foo@example.org")
@patch("hc.payments.models.braintree")
def test_it_retrieves_cc(self, mock):
mock.paypal_account.PayPalAccount = list
mock.credit_card.CreditCard = dict
mock.PaymentMethod.find.return_value = {"masked_number": "1***2"}
Subscription.objects.create(user=self.alice)
self.client.login(username="alice@example.org", password="password")
r = self.client.get("/accounts/profile/billing/payment_method/")
self.assertContains(r, "1***2")