test_l_createAndTrade.py 2.43 KB
import unittest
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from commons.MySession import hg,my
from commons import ConfigDB as db
from commons.api.hg.transaction.l_createAndTrade import l_createAndTrade
from commons.basic.registerRecord_save import registerRecord_save
lcat = l_createAndTrade()
r = registerRecord_save()

"""
创建普通客户订单
"""

class test_l_createAndTrade(unittest.TestCase):
    "创建普通客户订单"
    @classmethod
    def setUpClass(cls):
        # 新增一个进门批号单
        cls.aaa = db.mysql_selectOne('''SELECT
	aua.account_id AS "账号id",
	auc.card_no AS "园区卡号",
	aua.customer_id AS "客户id",
	aua.customer_code AS "客户code",
	aua.customer_name AS "客户姓名",
	aua.customer_certificate_number AS "客户身份证号码",
	aua.hold_contacts_phone AS "持卡人电话"
FROM
	 `dili_account`.`account_user_account` AS aua LEFT JOIN `dili_account`.`account_user_card` AS auc ON aua.account_id = auc.account_id 
WHERE
	aua.customer_id = 141969
ORDER BY
	aua.account_id DESC 
	LIMIT 1''')
        body2 = r.body3.copy()
        body2["accountId"] = str(cls.aaa[0])
        body2["cardNo"] = str(cls.aaa[1])
        body2["customerId"] = str(cls.aaa[2])
        body2["customerCode"] = str(cls.aaa[3])
        body2["customerName"] = str(cls.aaa[4])
        body2["identityCardNo"] = str(cls.aaa[5])
        body2["mobilephoneNumber"] = str(cls.aaa[6])
        body2["categoryId"] = 44
        body2["categoryCode"] = 754107
        body2["categoryName"] = "葡萄"
        print("批次号数据1", cls.aaa)
        print("批次号数据",body2)
        re = hg.post(url = r.url, headers = r.header, json = body2,proxies = my.proxies)
        "获取批号"
        print("获取批号结果:",re.json())
        cls.batch = re.json()["data"]["batchCode"]
        return cls.batch


    @unittest.case_mark(my.mark())
    def test_l_createAndTrade_01(self):
        "普通客户创建订单"
        body = lcat.body1.copy()
        body["orderItemList"][0]["batchCode"] = self.batch
        print("创建订单body",body)
        re1 = hg.post(url = lcat.url, headers = lcat.header, json = body,proxies = my.proxies)
        print(re1.json())
        self.assertEqual(re1.status_code, 200)
        # self.assertTrue("'操作成功'" in str(re1.json()).replace(" ", ""))
    @classmethod
    def tearDownClass(cls):
        pass


if __name__ == '__main__':
    unittest.main()