Пример #1
0
 def test_address(self):
     res = elements.Address(street_1='street_1',
                            street_2='street_2',
                            city='city',
                            postal_code='postal_code',
                            state='state',
                            country='country')
     expected = {
         'street_1': 'street_1',
         'street_2': 'street_2',
         'city': 'city',
         'postal_code': 'postal_code',
         'state': 'state',
         'country': 'country',
     }
     assert expected == res.to_dict()
Пример #2
0
 def test_receipt_template(self):
     element = elements.Element(
         title='Classic White T-Shirt',
         subtitle='100% Soft and Luxurious Cotton',
         quantity=2,
         price=50,
         currency='USD',
         image_url='http://petersapparel.parseapp.com/img/whiteshirt.png',
     )
     adjustment1 = elements.Adjustment(name='New Customer Discount',
                                       amount=20)
     adjustment2 = elements.Adjustment(name='$10 Off Coupon', amount=10)
     address = elements.Address(street_1='1 Hacker Way',
                                city='Menlo Park',
                                postal_code='94025',
                                state='CA',
                                country='US')
     summary = elements.Summary(subtotal=75.00,
                                shipping_cost=4.95,
                                total_tax=6.19,
                                total_cost=56.14)
     res = templates.ReceiptTemplate(
         recipient_name='Stephane Crozatier',
         order_number='12345678902',
         currency='USD',
         payment_method='Visa 2345',
         order_url='http://petersapparel.parseapp.com/order?order_id=123456',
         timestamp='1428444852',
         address=address,
         summary=summary,
         adjustments=[adjustment1, adjustment2],
         elements=[element])
     expected = {
         'attachment': {
             'type': 'template',
             'payload': {
                 'template_type':
                 'receipt',
                 'recipient_name':
                 'Stephane Crozatier',
                 'order_number':
                 '12345678902',
                 'currency':
                 'USD',
                 'payment_method':
                 'Visa 2345',
                 'order_url':
                 'http://petersapparel.parseapp.com/order?order_id=123456',
                 'timestamp':
                 '1428444852',
                 'elements': [{
                     'title':
                     'Classic White T-Shirt',
                     'subtitle':
                     '100% Soft and Luxurious Cotton',
                     'quantity':
                     2,
                     'price':
                     50,
                     'currency':
                     'USD',
                     'image_url':
                     'http://petersapparel.parseapp.com/img/whiteshirt.png'
                 }],
                 'address': {
                     'street_1': '1 Hacker Way',
                     'street_2': '',
                     'city': 'Menlo Park',
                     'postal_code': '94025',
                     'state': 'CA',
                     'country': 'US'
                 },
                 'summary': {
                     'subtotal': 75.00,
                     'shipping_cost': 4.95,
                     'total_tax': 6.19,
                     'total_cost': 56.14
                 },
                 'adjustments': [{
                     'name': 'New Customer Discount',
                     'amount': 20
                 }, {
                     'name': '$10 Off Coupon',
                     'amount': 10
                 }]
             }
         }
     }
     assert expected == res.to_dict()