forked from dj-stripe/dj-stripe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_email.py
45 lines (38 loc) · 1.27 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
import decimal
from django.core import mail
from django.test import TestCase
from mock import patch
from djstripe.models import Customer
from djstripe.settings import User
class EmailReceiptTest(TestCase):
def setUp(self):
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): # pylint: disable=C0301
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)