|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +import time |
| 3 | + |
| 4 | + |
| 5 | +def test_pay_schedule(iamport): |
| 6 | + schedule_at = int(time.time() + 1000) |
| 7 | + |
| 8 | + payload_without_customer_uid = { |
| 9 | + # without 'customer_uid' |
| 10 | + 'schedules': [ |
| 11 | + { |
| 12 | + 'merchant_uid': 'pay_schedule_%s' % str(time.time()), |
| 13 | + 'schedule_at': schedule_at, |
| 14 | + 'amount': 2001, |
| 15 | + 'name': '주문명1', |
| 16 | + 'buyer_name': '주문자명', |
| 17 | + 'buyer_email': '주문자 Email주소', |
| 18 | + 'buyer_tel': '주문자 전화번호', |
| 19 | + 'buyer_addr': '주문자 주소', |
| 20 | + 'buyer_postcode': '주문자 우편번호' |
| 21 | + }, |
| 22 | + ], |
| 23 | + } |
| 24 | + |
| 25 | + try: |
| 26 | + iamport.pay_schedule(**payload_without_customer_uid) |
| 27 | + except KeyError as e: |
| 28 | + assert 'customer_uid is required' in str(e) |
| 29 | + |
| 30 | + payload_without_merchant_uid = { |
| 31 | + 'customer_uid': '00000000', |
| 32 | + 'schedules': [ |
| 33 | + { |
| 34 | + # without 'merchant_uid' |
| 35 | + 'schedule_at': schedule_at, |
| 36 | + 'amount': 10000, |
| 37 | + 'name': '주문명2', |
| 38 | + 'buyer_name': '주문자명', |
| 39 | + 'buyer_email': '주문자 Email주소', |
| 40 | + 'buyer_tel': '주문자 전화번호', |
| 41 | + 'buyer_addr': '주문자 주소', |
| 42 | + 'buyer_postcode': '주문자 우편번호' |
| 43 | + }, |
| 44 | + ], |
| 45 | + } |
| 46 | + |
| 47 | + try: |
| 48 | + iamport.pay_schedule(**payload_without_merchant_uid) |
| 49 | + except KeyError as e: |
| 50 | + assert 'Essential parameter is missing!: merchant_uid' in str(e) |
| 51 | + |
| 52 | + payload_full = { |
| 53 | + 'customer_uid': '00000000', |
| 54 | + 'schedules': [ |
| 55 | + { |
| 56 | + 'merchant_uid': 'pay_schedule_%s' % str(time.time()), |
| 57 | + 'schedule_at': schedule_at, |
| 58 | + 'amount': 5000, |
| 59 | + 'name': '주문명', |
| 60 | + 'buyer_name': '주문자명', |
| 61 | + 'buyer_email': '주문자 Email주소', |
| 62 | + 'buyer_tel': '주문자 전화번호', |
| 63 | + 'buyer_addr': '주문자 주소', |
| 64 | + 'buyer_postcode': '주문자 우편번호' |
| 65 | + }, |
| 66 | + ], |
| 67 | + } |
| 68 | + |
| 69 | + try: |
| 70 | + iamport.pay_schedule(**payload_full) |
| 71 | + except iamport.ResponseError as e: |
| 72 | + assert e.code == 1 |
| 73 | + assert u'등록되지 않은 구매자입니다.' in e.message |
0 commit comments