test_generalCustomerLoan.py 4.29 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
from  commons import common as com
from commons import ConfigDB as db
from commons.MySession import my,hg
from commons.api.hg.loan_generalCustomer.generalCustomerLoan_save import generalCustomerLoan_save
from commons.api.hg.loan_generalCustomer.generalCustomerLoan_delete import generalCustomerLoan_delete
from commons.api.hg.loan_generalCustomer.generalCustomerLoan_list import generalCustomerLoan_list
from commons.api.hg.loan_generalCustomer.generalCustomerLoan_enforce import generalCustomerLoan_enforce
from commons.basic.registerRecord_save import registerRecord_save
from commons.basic.createAndTrade import createAndTrade
g=generalCustomerLoan_save()
l=generalCustomerLoan_list()
d=generalCustomerLoan_delete()
e=generalCustomerLoan_enforce()
r=registerRecord_save()
c=createAndTrade()


class test_generalCustomerLoan(unittest.TestCase):
    "杭果市场-借款管理-普通客户借款"

    @classmethod
    def setUpClass(cls) :
        #存储进门的批次号
        cls.batch=[]
        #生成两单进门批号
        for i in range(2):
            #新增一个进门批号单
            re=hg.post(url=r.url,headers=r.header,json=r.body1)
            #获取批号
            cls.batch.append(re.json()["data"]["batchCode"])
            #普通客户使用进门批号生成交易单
            body=c.body1.copy()
            body["orderItemList"][0]["batchCode"]=cls.batch
            re1=hg.post(url=c.url,headers=c.header,json=body)


    @unittest.case_mark(my.mark())
    def test_generalCustomerLoan_01_save(self):
        "新增预支款:根据批次号新增预支款"
        #生成两个普通借款单
        for i in range(2):
            #替换批次号
            body=g.body.copy()
            body["batch"]=self.batch[i]
            #请求
            re=hg.post(url=g.url,headers=g.header,json=body)
            print(re.json(),"普通借款批次号",self.batch[i])
            self.assertEqual(re.status_code, 200)
            self.assertTrue("操作成功" in str(re.json()).replace(" ",""))


    @unittest.skipDepend(depend="test_generalCustomerLoan_01_save")
    @unittest.case_mark(my.mark())
    def test_generalCustomerLoan_02_list(self):
        "列表-查询:执行状态,客户,批号和结算日期都输入合法值,查询指定借款数据"
        #修改查询的值
        body=l.body.copy()
        body["batch"] = self.batch[0]
        # body["settleDateStart"]=com.dates()
        # body["settleDateEnd"] = com.dates()
        #请求
        re=hg.post(url=l.url,headers=l.header,json=body)
        print(re.json())
        #断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("操作成功" in str(re.json()).replace(" ",""))
        self.assertTrue(self.batch[0] in str(re.json()).replace(" ",""))


    @unittest.skipDepend(depend="test_generalCustomerLoan_01_save")
    @unittest.case_mark(my.mark())
    def test_generalCustomerLoan_03_delete(self):
        "列表-撤销:撤销一个未执行的借款单"
        #查询批次号对应id
        batch_id=db.mysql_selectOne(d.sql.replace("2109000088",self.batch[0]))[0]
        #替换url的批次id
        url=d.url.replace("66",str(batch_id))
        #请求
        re=hg.get(url=url,headers=d.header)
        print(re.json(),"删除的普通借款批次号号和id",self.batch[0],batch_id)
        #断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("操作成功" in str(re.json()).replace(" ",""))


    @unittest.skipDepend(depend="test_generalCustomerLoan_01_save")
    @unittest.case_mark(my.mark())
    def test_generalCustomerLoan_04_enforce(self):
        "列表-执行:执行一个未执行的借款单"
        #查询批次号对应id
        batch_id=db.mysql_selectOne(d.sql.replace("2109000088",self.batch[1]))[0]
        #替换url的批次id
        url=e.url.replace("66",str(batch_id))
        #请求
        re=hg.get(url=url,headers=e.header)
        print(re.json(),"执行的普通借款批次号号和id",self.batch[1],batch_id)
        #断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("操作成功" in str(re.json()).replace(" ",""))



if __name__ == "__main__":

    unittest.main(verbosity=2)
    # com.run_one(test_generalCustomerLoan("test_generalCustomerLoan_01_save"))