-
Notifications
You must be signed in to change notification settings - Fork 286
/
test_email.py
47 lines (40 loc) · 1.3 KB
/
test_email.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# pylint: disable=C0301
import decimal
from django.core import mail
from django.test import TestCase
from mock import patch
from ..models import Customer
from ..utils import get_user_model
class EmailReceiptTest(TestCase):
def setUp(self):
User = get_user_model()
self.user = User.objects.create_user(username="patrick")
self.customer = Customer.objects.create(
user=self.user,
stripe_id="cus_xxxxxxxxxxxxxxx",
card_fingerprint="YYYYYYYY",
card_last_4="2342",
card_kind="Visa"
)
@patch("stripe.Charge.retrieve")
@patch("stripe.Charge.create")
def test_email_reciept_renders_amount_properly(self, ChargeMock, RetrieveMock):
ChargeMock.return_value.id = "ch_XXXXX"
RetrieveMock.return_value = {
"id": "ch_XXXXXX",
"card": {
"last4": "4323",
"type": "Visa"
},
"amount": 40000,
"paid": True,
"refunded": False,
"fee": 499,
"dispute": None,
"created": 1363911708,
"customer": "cus_xxxxxxxxxxxxxxx"
}
self.customer.charge(
amount=decimal.Decimal("400.00")
)
self.assertTrue("$400.00" in mail.outbox[0].body)