# -*- coding: utf-8 -*-
import time


def test_pay_schedule(iamport):
    schedule_at = int(time.time() + 1000)

    payload_without_customer_uid = {
        # without 'customer_uid'
        'schedules': [
            {
                'merchant_uid': 'pay_schedule_%s' % str(time.time()),
                'schedule_at': schedule_at,
                'amount': 2001,
                'name': '주문명1',
                'buyer_name': '주문자명',
                'buyer_email': '주문자 Email주소',
                'buyer_tel': '주문자 전화번호',
                'buyer_addr': '주문자 주소',
                'buyer_postcode': '주문자 우편번호'
            },
        ],
    }

    try:
        iamport.pay_schedule(**payload_without_customer_uid)
    except KeyError as e:
        assert 'customer_uid is required' in str(e)

    payload_without_merchant_uid = {
        'customer_uid': '00000000',
        'schedules': [
            {
                # without 'merchant_uid'
                'schedule_at': schedule_at,
                'amount': 10000,
                'name': '주문명2',
                'buyer_name': '주문자명',
                'buyer_email': '주문자 Email주소',
                'buyer_tel': '주문자 전화번호',
                'buyer_addr': '주문자 주소',
                'buyer_postcode': '주문자 우편번호'
            },
        ],
    }

    try:
        iamport.pay_schedule(**payload_without_merchant_uid)
    except KeyError as e:
        assert 'Essential parameter is missing!: merchant_uid' in str(e)

    payload_full = {
        'customer_uid': '00000000',
        'schedules': [
            {
                'merchant_uid': 'pay_schedule_%s' % str(time.time()),
                'schedule_at': schedule_at,
                'amount': 5000,
                'name': '주문명',
                'buyer_name': '주문자명',
                'buyer_email': '주문자 Email주소',
                'buyer_tel': '주문자 전화번호',
                'buyer_addr': '주문자 주소',
                'buyer_postcode': '주문자 우편번호'
            },
        ],
    }

    try:
        iamport.pay_schedule(**payload_full)
    except iamport.ResponseError as e:
        assert e.code == 1
        assert u'등록되지 않은 구매자입니다.' in e.message

@@ -2113,18 +2113,18 @@
 u'%EB%93%B1%EB%A1%9D
-%EB%90%98%EC%A7%80 %EC%95%8A%EC%9D%80 %EA%B5%AC%EB%A7%A4%EC%9E%90%EC%9E%85
+%EB%90%9C %EA%B3%A0%EA%B0%9D%EC%A0%95%EB%B3%B4%EA%B0%80 %EC%97%86%EC%8A%B5
 %EB%8B%88%EB%8B%A4.'

Refactor assertion message in test_pay_schedule