Example #1
0
    def __init__(self, sec_name):
        mysql = ReadYaml(mysql_path)

        # 读取mysql配置文件
        self.mysql_conf = mysql.getValue(sec_name)

        # 获取mysql的数据
        self.connect = pymysql.Connect(
            host = self.mysql_conf['url'],
            port = self.mysql_conf['port'],
            user = str(self.mysql_conf['username']),
            passwd = str(self.mysql_conf['password']),
            db = self.mysql_conf['db'],
            charset = 'utf8'
        )

        self.cursor = self.connect.cursor()
        logs.info('成功连接数据库')
Example #2
0
import requests
import json
import allure
from urllib.parse import urlencode
import time
from common.read_yaml import ReadYaml

data = ReadYaml("data.yml").get_yaml_data()  # 读取数据


class HttpClient:
    def __init__(self):
        self.host = data['otc_app_host']

    default_header = {
        "Content-Type": "application/json",
        "sd_origin": "shendu-dev1.sdpjw.cn"
    }

    def send(self,
             url,
             body={},
             method='get',
             headers={},
             sessions=0,
             x_token=0,
             need_rsp=True):

        headers.update(self.default_header)
        if sessions:
            headers["Session"] = sessions
class TestSrmCp:
    log = Log()
    testdata = ReadYaml("case_data.yml").get_yaml_data()

    @pytest.mark.parametrize("key,value,expect",
                             testdata["cpLackMaterialSub_page_data"],
                             ids=["查询采购申请号", "查询备注"])
    @allure.feature('采购申请查询接口')  # 测试报告显示测试功能
    def test_cpLackMaterialSub_page(self, gettokenfixture, key, value, expect):
        s = gettokenfixture
        self.log.info("----采购申请查询接口口----")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_page(key, value)
        self.log.info("获取请求结果: %s" % msg.json())
        if key == "purchaseRequestNo":
            result = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0]
            assert result == expect
        else:
            result = jsonpath.jsonpath(msg.json(), '$..remark')[0]
            assert expect in result

    @pytest.mark.parametrize("caigouyuan,expect",
                             testdata["cpLackMaterialSub_save_data"],
                             ids=["修改采购员为杨波保存", "修改采购员为钟子鉴保存"])
    @allure.feature('采购申请保存接口')
    def test_cpLackMaterialSub_save(self, gettokenfixture, caigouyuan, expect):
        s = gettokenfixture
        self.log.info("-----采购申请保存接口-----")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_save(caigouyuan)
        jg = msg[0]
        self.log.info("获取请求结果:%s" % jg.json())
        rem = r.cpLackMaterialSub_page("purchaseRequestNo", "PR2021032000011")
        print(rem.json())
        rem.cgy = jsonpath.jsonpath(rem.json(), '$..buyerAccount')[0]
        rem.rem = jsonpath.jsonpath(rem.json(), '$..remark')[0]
        assert jg.json()["success"] == 1
        assert rem.cgy == expect
        assert rem.rem == "{}".format(msg[1])

    @pytest.mark.parametrize("code, caigouyuan, expect",
                             testdata["cpLackMaterialSub_push_data"],
                             ids=["zzj提交物料1", "yb提交物料2", "zzj提交物料3"])
    @allure.feature('采购申请提交')
    def test_cpLackMaterialSub_push(self, gettokenfixture, code, caigouyuan,
                                    expect):
        s = gettokenfixture
        self.log.info("----采购申请提交接口----")
        r = SRMBase(s)
        uid = r.srm_uuid()
        r.cpLackMaterialSub_Temp(uid, code, demand=1)
        msg = r.cpLackMaterialSub_push(uid, caigouyuan)
        result = msg[0]
        self.log.info("获取请求结果{}".format(result.json()))
        uu = msg[1]
        ass_uu = r.cpLackMaterialSub_page("remark", uu)
        ass_remark = jsonpath.jsonpath(ass_uu.json(), '$..remark')[0]
        assert result.json()["success"] == 1
        assert result.status_code == 200
        assert ass_remark == "{}".format(uu)

    @pytest.mark.parametrize("p_id, expect",
                             testdata["cpLackMaterialSub_delete_data"],
                             ids=["正常删除", "删除已发布的数据", "删除已关闭的数据", "删除已完成的数据"])
    @allure.feature('采购申请删除')
    def test_cpLackMaterialSub_delete(self, gettokenfixture, cgsqdelete_sql,
                                      p_id, expect):
        s = gettokenfixture
        self.log.info("---采购申请删除接口---")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_delete(p_id)
        print(msg.json())
        STATUS_sql = "SELECT STATUS FROM CP_PURCHASE_REQUEST WHERE PURCHASE_REQUEST_ID = '{}'".format(
            p_id)
        STATE_sql = "SELECT STATE FROM CP_PURCHASE_REQUEST WHERE PURCHASE_REQUEST_ID = '{}'".format(
            p_id)
        jg = Db_Oracle().select(STATUS_sql)
        jh = Db_Oracle().select(STATE_sql)
        ass_jg = jg['STATUS']
        ass_jh = jh['STATE']
        if ass_jg == 100:
            assert ass_jh == 0
        else:
            assert msg.json()["msg"] == expect

    @pytest.mark.parametrize("file",
                             testdata["cpLackMaterialSub_leadin_data"],
                             ids=["导入正确数据", "导入错误数据"])
    @allure.feature('采购申请导入')
    def test_cpLackMaterialSub_leadin(self, gettokenfixture, file):
        s = gettokenfixture
        self.log.info("---采购申请导入---")
        r = SRMBase(s)
        count = r.cpLackMaterialSub_count("createBy", "zhongzijian")
        ass = count.json()["data"]["total"]
        msg = r.cpLackMaterialSub_leadin(file)
        self.log.info("导入结果是%s" % msg.json())
        r.cpLackMaterialSub_leadin_commit()
        count2 = r.cpLackMaterialSub_count("createBy", "zhongzijian")
        ass2 = count2.json()["data"]["total"]
        if file == "c:/cpLackMaterialSub_leadin.xlsx":
            assert ass2 - 1 == ass
        else:
            assert ass2 == ass

    @pytest.mark.parametrize("c1, expect",
                             testdata["cpLackMaterialSub_leadin_edit_data"],
                             ids=["改成正确数据", "改成错误数据"])
    @allure.feature('采购申请编辑与清空')
    def test_cpLackMaterialSub_leadin_edit(self, cgsqclear, c1, expect):
        s = cgsqclear
        self.log.info("采购申请编辑与清空")
        r = SRMBase(s)
        leadin = r.cpLackMaterialSub_leadin("c:/cpLackMaterialSub_leadin.xlsx")
        self.log.info("导入结果是%s" % leadin.json())
        data = r.cpLackMaterialSub_leadin_page("column12", "自动化导入")
        self.log.info("查询结果是{}".format(data.json()))
        lid = jsonpath.jsonpath(data.json(), '$..id')[0]
        self.log.info("抓取到lid是%s" % lid)
        r.cpLackMaterialSub_leadin_edit(lid, c1)
        msg = r.cpLackMaterialSub_leadin_page("column12", "自动化导入")
        msg_id = jsonpath.jsonpath(msg.json(), '$..column1')[0]
        assert msg_id == expect

    @pytest.mark.prod
    @pytest.mark.parametrize("detailstatus, status, ds_expect, s_expect",
                             testdata["cpdetail_statuspage_data"],
                             ids=[
                                 "查询待提交", "查询已发布", "查询已关闭", "查询已完成", "查询未分配",
                                 "查询部分分配", "查询部分转单", "查询部分下单", "查询已分配",
                                 "查询已转单", "查询明细完成", "查询明细已关闭"
                             ])
    @allure.feature('采购申请明细状态查询')
    def test_cpdetail_statuspage_data(self, gettokenfixture, detailstatus,
                                      status, ds_expect, s_expect):
        s = gettokenfixture
        self.log.info("---采购申请明细状态查询---")
        r = SRMBase(s)
        msg = r.cpdetail_statuspage(detailstatus, status)
        ass_ds = jsonpath.jsonpath(msg.json(), '$..requestDetailStatus')[0]
        ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_ds)
        ass2 = repr(ass_s)
        assert ass1 in ds_expect
        assert ass2 in s_expect

    @pytest.mark.parametrize("key,value,expect",
                             testdata["cpdetail_page_data"],
                             ids=["查询采购申请号", "查询物料", "查询采购员"])
    @allure.feature('采购申请明细查询接口口')
    def test_cpdetail_page(self, gettokenfixture, key, value, expect):
        s = gettokenfixture
        self.log.info("----采购申请明细查询接口口----")
        r = SRMBase(s)
        msg = r.cpdetail_page(key, value)
        self.log.info("获取请求结果: %s" % msg.json())
        if key == "purchaseRequestNo":
            result = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0]
            assert result == expect
        elif key == "materialCode":
            result = jsonpath.jsonpath(msg.json(), '$..materialCode')[0]
            assert result == expect
        else:
            result = jsonpath.jsonpath(msg.json(), '$..buyerAccount')[0]
            assert result == expect

    @pytest.mark.parametrize("value,expect",
                             testdata["cpdetail_userpage_data"],
                             ids=["查询采购员wx", "查询采购员zzj"])
    @allure.feature('转交采购员查询接口')
    def test_cpdetail_userpage(self, gettokenfixture, value, expect):
        s = gettokenfixture
        self.log.info("---转交采购员查询接口---")
        r = SRMBase(s)
        msg = r.cpdetail_userpage(value)
        self.log.info("获取请求结果:%s" % msg.json())
        assert msg.json()["msg"] == expect["msg"]

    @pytest.mark.parametrize("account",
                             testdata["cpdetail_transfer_data"],
                             ids=["转交采购员wx", "转交采购员zzj"])
    @allure.feature('采购申请明细转交接口')
    def test_cpdetail_transfer(self, gettokenfixture, account):
        s = gettokenfixture
        self.log.info("---采购申请明细转交接口---")
        r = SRMBase(s)
        r.cpdetail_transfer(account)
        msg = r.cpdetail_page("purchaseRequestNo", "PR2021042000011")
        self.log.info("转交后查询结果:%s" % msg.json())
        ass = jsonpath.jsonpath(msg.json(), '$..buyerAccount')[0]
        assert ass == account

    @allure.feature('采购申请明细导出接口')
    def test_cpdetail_report(self, gettokenfixture):
        s = gettokenfixture
        r = SRMBase(s)
        self.log.info("---采购申请明细导出---")
        msg = r.cpdetail_report()
        assert msg.status_code == 200

    @allure.feature('采购申请查看-获取供应商接口')
    def test_cpselect_vendor(self, gettokenfixture):
        s = gettokenfixture
        self.log.info('---采购申请查看-获取供应商接口---')
        r = SRMBase(s)
        msg = r.cpselect_vendor()
        assert msg.status_code == 200

    @allure.feature('采购申请查看-获取公司接口')
    def test_cpselect_baseCompany(self, gettokenfixture):
        s = gettokenfixture
        self.log.info('---采购申请查看-获取公司接口---')
        r = SRMBase(s)
        msg = r.cpselect_baseCompany()
        assert msg.status_code == 200

    @allure.feature("采购申请查看-获取采购员接口")
    def test_cpselect_sysUser(self, gettokenfixture):
        s = gettokenfixture
        self.log.info('---采购申请查看-获取采购员接口---')
        r = SRMBase(s)
        msg = r.cpselect_sysUser()
        assert msg.json()["msg"] == "获取用户成功"

    @allure.feature("采购申请查看-获取主单接口")
    def test_cpselect_main(self, gettokenfixture):
        s = gettokenfixture
        self.log.info('---采购申请查看-获取主单接口---')
        r = SRMBase(s)
        msg = r.cpselect_main()
        self.log.info('获取结果是:%s' % msg.json())
        assert msg.json(
        )["data"]["tempId"] == "8e926428-c823-418d-9264-28c823a18d03"

    @allure.feature("采购申请查看-获取明细接口")
    def test_cpselect_temp(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("---采购申请查看-获取明细接口---")
        r = SRMBase(s)
        msg = r.cpselect_temp()
        self.log.info('获取结果是:%s' % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..tempId')[0]
        assert a_msg == "8e926428-c823-418d-9264-28c823a18d03"

    @allure.feature("采购申请查看-获取日志接口")
    def test_cpselect_log(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("---采购申请查看-获取日志接口---")
        r = SRMBase(s)
        msg = r.cpselect_log()
        self.log.info("获取结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..busId')[0]
        assert a_msg == "8e926428-c823-418d-9264-28c823a18d03"

    @pytest.mark.parametrize("syncstatus, status, ss_expect, s_expect",
                             testdata["cp_statuspage_data"],
                             ids=[
                                 "查询待提交", "查询已发布", "查询已关闭", "查询已完成", "查询未同步",
                                 "查询同步中", "查询同步失败", "查询同步成功", "查询不同步"
                             ])
    @allure.feature("采购申请状态查询接口")
    def test_cp_statuspage(self, gettokenfixture, syncstatus, status,
                           ss_expect, s_expect):
        s = gettokenfixture
        self.log.info("采购申请状态查询接口")
        r = SRMBase(s)
        msg = r.cp_statuspage(syncstatus, status)
        self.log.info("获取结果是:%s" % msg.json())
        ass_ss = jsonpath.jsonpath(msg.json(), '$..syncStatus')[0]
        ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_ss)
        ass2 = repr(ass_s)
        assert ass1 in ss_expect
        assert ass2 in s_expect

    @pytest.mark.parametrize("status, expect",
                             testdata["cp_examineRecordsPage_data"],
                             ids=["查询待审核", "查询审核未通过", "查询已通过"])
    @allure.feature("配额超标审核记录状态查询")
    def test_cp_examineRecordsPage(self, gettokenfixture, status, expect):
        s = gettokenfixture
        self.log.info("配额超标审核记录状态查询")
        r = SRMBase(s)
        msg = r.cp_examineRecordsPage(status)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..status')[0]
        assert a_msg == expect

    @pytest.mark.parametrize("key, value",
                             testdata["cp_examineRecordsPg_data"],
                             ids=["查询采购申请单号", "查询物料编码"])
    @allure.feature("配额超标审核记录查询")
    def test_cp_examineRecordsPg(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("配额超标审核记录查询")
        r = SRMBase(s)
        msg = r.cp_examineRecordsPg(key, value)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0]
        b_msg = jsonpath.jsonpath(msg.json(), '$..materialCode')[0]
        if key == "purchaseRequestNo":
            assert a_msg == value
        else:
            assert b_msg == value

    @pytest.mark.parametrize("key, status, expect",
                             testdata["cp_zdstatusPage_data"],
                             ids=[
                                 "查询未分配", "查询部分分配", "查询部分转单", "查询部分下单",
                                 "查询已分配", "查询已转单", "查询已完成", "查询已关闭"
                             ])
    @allure.feature("采购申请转单状态查询")
    def test_cp_zdstatusPage(self, gettokenfixture, key, status, expect):
        s = gettokenfixture
        self.log.info("采购申请转单状态查询")
        r = SRMBase(s)
        msg = r.cp_zdstatusPage(key, status)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..requestDetailStatus')[0]
        assert a_msg == expect

    @pytest.mark.parametrize("key, value, expect",
                             testdata["cp_zdpage_data"],
                             ids=["查询备注", "查询创建人"])
    @allure.feature("采购申请转单查询")
    def test_cp_zdpage(self, gettokenfixture, key, value, expect):
        s = gettokenfixture
        self.log.info("采购申请转单查询")
        r = SRMBase(s)
        msg = r.cp_zdpage(key, value)
        self.log.info("获取请求结果:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..requestDetailRemark')[0]
        b_msg = jsonpath.jsonpath(msg.json(), '$..createBy')[0]
        if key == "requestDetailRemark":
            assert a_msg == expect
        else:
            assert b_msg == expect

    @allure.feature("采购申请明细分配查询")
    def test_cp_zdqueryAllpage(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("采购申请明细分配查询")
        r = SRMBase(s)
        msg = r.cp_zdqueryAllpage()
        self.log.info("获取结果是:%s" % msg.json())
        assert "allotQty" in msg.text

    @pytest.mark.parametrize("bool, expect",
                             testdata["cp_cpzdcommit_data"],
                             ids=["采购申请转单提交", "采购申请转单保存"])
    @allure.feature("采购申请转单提交与保存")
    def test_cpzdcommit(self, gettokenfixture, bool, expect):
        s = gettokenfixture
        self.log.info("---采购申请转单提交---")
        r = SRMBase(s)
        try:
            msg_getRequestid = r.cp_zdpage("requestDetailRemark",
                                           "自动化导入")  # 查询目标采购申请
            Requestid = jsonpath.jsonpath(msg_getRequestid.json(),
                                          '$..purchaseRequestId')[0]
            Detailid = jsonpath.jsonpath(msg_getRequestid.json(),
                                         '$..requestDetailId')[0]
            self.log.info("获取采购申请ID:%s" % Requestid)
        except:
            self.log.error("自动化导入数据已耗尽")
        msg_allotDty = r.cp_zdallotDty(Requestid, Detailid)  # 分配采购申请
        Alloid = msg_allotDty.json()["data"][0]
        self.log.info("分配的ID是:%s" % msg_allotDty.json()["data"][0])
        msg_commit = r.cp_zdcommit(Requestid, Detailid, Alloid)  # 分配页面的提交
        self.log.info("提交的结果是:%s" % msg_commit.json())
        msg_traceid = r.cp_queryByCompanyVendor("500973", "6100",
                                                "A01")  # 获取可提交明细
        for jg in msg_traceid.json()['data']:
            if jg['requestAllotId'] == Alloid:
                break
        Tranceid = jg['requestTransferId']
        msg_jlcommit = r.cp_zdjlcommit(Tranceid, Detailid, Alloid)  # 转单页面的提交
        tempid = msg_jlcommit.json()["data"]["tempId"]
        self.log.info("获取的tempID是:%s" % tempid)
        msg_page = r.cp_ordertempPage(tempid)  # 根据tempid查询获取传参
        detailtempid = jsonpath.jsonpath(msg_page.json(), '$..detailTempId')[0]
        orderdetailid = jsonpath.jsonpath(msg_page.json(),
                                          '$..orderDetailId')[0]
        msg_put = r.cp_orderDetailEdit(tempid, detailtempid, Tranceid,
                                       orderdetailid)  #更新采购订单明细
        try:
            msg_jccommit = r.cp_cgsqjccommit(tempid, bool)  # 最后提交采购订单
            self.log.info("生成采购订单号是:%s" % msg_jccommit.json()["msg"])
        except:
            self.log.error("采购订单提交失败")
        msg = r.cp_orderpage("purchaseOrderNo", msg_jccommit.json()["msg"])
        status = jsonpath.jsonpath(msg.json(), '$..status')[0]
        assert msg.json()["data"]["total"] == 1
        assert status == expect

    @allure.feature("采购申请转单取消分配")
    def test_cpzdcancel(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("采购申请转单取消分配")
        r = SRMBase(s)
        RequestsNo = r.cp_zdstatusPage("requestDetailStatus100", "100")
        print("请求结果是%s" % RequestsNo.text)
        No = jsonpath.jsonpath(RequestsNo.json(), '$..purchaseRequestNo')[0]
        Requestid = jsonpath.jsonpath(RequestsNo.json(),
                                      '$..purchaseRequestId')[0]
        Detailid = jsonpath.jsonpath(RequestsNo.json(),
                                     '$..requestDetailId')[0]
        Dty = r.cp_zdallotDty(Requestid, Detailid)
        Alloid = Dty.json()["data"][0]
        msg = r.cp_zdcacle(Alloid, Requestid, Detailid, No)
        self.log.info("取消结果是:%s" % msg.text)
        ass_No = r.cp_zdpage("purchaseRequestNo", No)
        assert ass_No.json()["data"]["total"] == 1

    @allure.feature("采购申请转单取消")
    def test_cpPurchase_cancel(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("采购申请转单取消")
        r = SRMBase(s)
        data = r.cp_queryByCompanyVendor("500973", "6100", "A01")
        print(data.json())
        for i in data.json()['data']:
            if i['purchaseRequestNo'] == "purchaseRequestNo":
                break
        TransferId = i["requestTransferId"]
        batchFlag = i["batchFlag"]
        cancel = r.cpPurchase_cancel(batchFlag, TransferId)
        self.log.info("取消返回结果:%s" % cancel.text)
        msg = r.cp_zdqueryAllpage()
        reset = r.cp_zdcommit("8e926428-c823-418d-9264-28c823a18d03",
                              "448ad576-bcc5-4689-8ad5-76bcc5d68971",
                              "8ce3691f-136f-49c6-a369-1f136ff9c6a0")
        for j in msg.json()['data']:
            if j['purchaseRequestNo'] == "PR2021042100008":
                break
        assert j["purchaseRequestNo"] == "PR2021042100008"

    @pytest.mark.parametrize("auditFlag, expect",
                             testdata["cp_audit_data"],
                             ids=["审核通过", "审核驳回"])
    @allure.feature("配额超标审核")
    def test_cpPurchaseRequestOverproof(self, gettokenfixture, auditFlag,
                                        expect):
        s = gettokenfixture
        self.log.info("----采购申请配额超标审核----")
        r = SRMBase(s)
        uid = r.srm_uuid()
        r.cpLackMaterialSub_Temp(uid, code="105000007", demand=401)  # 超标采购申请新增
        msg = r.cpLackMaterialSub_push(uid, caigouyuan="zhongzijian")
        result = msg[0]
        self.log.info("获取新增结果{}".format(result.json()))
        try:
            msg_getRequestid = r.cp_zdpage(key="materialCode",
                                           value="105000007")  # 查询目标采购申请
            Requestid = jsonpath.jsonpath(msg_getRequestid.json(),
                                          '$..purchaseRequestId')[0]
            Detailid = jsonpath.jsonpath(msg_getRequestid.json(),
                                         '$..requestDetailId')[0]
            self.log.info("获取采购申请ID:%s" % Requestid)
        except:
            self.log.error("获取采购申请数据错误")
        msg_allotDty = r.cp_zdallotDty(Requestid, Detailid)  # 分配采购申请
        Alloid = msg_allotDty.json()["data"][0]
        commit = r.cp_zdcomits(Requestid, Detailid, Alloid)  #分配页面提交
        sql = "UPDATE BUSINESS_WAIT_APPROVE_RECORD SET APPROVE_BY = 'zhongzijian' WHERE PROCESS_NAME = '采购申请超标审批流'"
        Db_Oracle().update(sql)
        page = r.cp_customPage("materialCode", "105000007")
        auditid = jsonpath.jsonpath(page.json(), '$..requestOverproofId')[0]
        purchaseRequestNo = jsonpath.jsonpath(page.json(),
                                              '$..purchaseRequestNo')[0]
        msg = r.cp_audit(auditid, auditFlag)
        self.log.info("审核结果是:%s" % msg.json())
        ass = r.cp_examineRecordsPg("purchaseRequestNo", purchaseRequestNo)
        status = jsonpath.jsonpath(ass.json(), '$..status')[0]
        assert status == expect

    @pytest.mark.parametrize("key, value",
                             testdata["cp_customPage_data"],
                             ids=["查询单号", "查询物料"])
    @allure.feature("配额超标审核查询")
    def test_customPage(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("配额超标审核查询")
        r = SRMBase(s)
        msg = r.cp_customPage(key, value)
        self.log.info("查询结果为:%s" % msg.json())
        purchaseRequestNo = jsonpath.jsonpath(msg.json(),
                                              '$..purchaseRequestNo')[0]
        materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0]
        if key == "materialCode":
            assert materialCode == value
        else:
            assert purchaseRequestNo == value

    @pytest.mark.parametrize(
        "key, value",
        testdata["cpLackMaterialSub_statusPage_Data"],
        ids=["查询待提交", "查询采购员待确认", "查询库房待收货", "查询库房收货中", "查询完成"])
    @pytest.mark.prod
    @allure.feature("缺料提报状态查询")
    def test_cpLackMaterialSub_statusPage(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("缺料提报状态查询接口")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_statusPage(key, value)
        status = jsonpath.jsonpath(msg.json(), '$..status')[0]
        self.log.info("查询结果是:%s" % msg.json())
        assert status == value

    @pytest.mark.parametrize("key, value",
                             testdata["cpLackMaterialSub_qlpage_Data"],
                             ids=["查询缺料提报编码", "查询物料", "查询提报人"])
    @pytest.mark.prod
    @allure.feature("缺料提报查询")
    def test_cpLackMaterialSub_statusPage(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("缺料提报查询接口")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_qlpage(key, value)
        lackMaterialSubNo = jsonpath.jsonpath(msg.json(),
                                              '$..lackMaterialSubNo')[0]
        materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0]
        createBy = jsonpath.jsonpath(msg.json(), '$..createBy')[0]
        self.log.info("查询结果是:%s" % msg.json())
        if key == "lackMaterialSubNo":
            assert lackMaterialSubNo == value
        elif key == "materialCode":
            assert materialCode == value
        else:
            assert createBy == value

    @allure.feature("根据公司查询工厂")
    def test_basePlant(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("根据公司查询工厂")
        r = SRMBase(s)
        msg = r.basePlant()
        self.log.info("查询第一条结果是:%s" % msg.json()["data"][0])
        assert msg.json()["msg"] == "查询成功"

    @allure.feature("根据工厂查询库位")
    def test_baseStorageLocation(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("根据工厂查询库位")
        r = SRMBase(s)
        msg = r.baseStorageLocation()
        self.log.info("查询第一条结果是:%s" % msg.json()["data"][0])
        assert msg.json()["msg"] == "查询成功"

    @allure.feature("根据工厂获取物料")
    def test_customByPlantPage(self, gettokenfixture):
        s = gettokenfixture
        self.log.info("根据工厂获取物料")
        r = SRMBase(s)
        msg = r.customByPlantPage()
        self.log.info("查询到第一页条数是:%s" % msg.json()["data"]["total"])
        assert msg.json()["success"] == 1
        assert msg.json()["data"]["total"] == 6

    @pytest.mark.parametrize("processamento",
                             testdata["cpLackMaterialSub_add_data"],
                             ids=["新增质量不合格缺料提报", "新增有货不可用缺料提报", "新增采购缺料提报"])
    @allure.feature("缺料提报新增")
    def test_cpLackMaterialSub_add(self, gettokenfixture, processamento):
        s = gettokenfixture
        self.log.info("缺料提报新增")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_add(processamento)
        ass = r.cpLackMaterialSub_qlpage("productName", msg[1])
        ass_processamento = jsonpath.jsonpath(ass.json(),
                                              '$..processamento')[0]
        assert ass_processamento == processamento

    @pytest.mark.parametrize(
        "processamento",
        testdata["cpLackMaterialSub_Save_Data"],
        ids=["新增质量不合格缺料提报保存", "新增有货不可用缺料提报保存", "新增采购缺料提报保存"])
    @allure.feature("缺料提报保存")
    def test_cpLackMaterialSub_Save(self, gettokenfixture, processamento):
        s = gettokenfixture
        self.log.info("缺料提报保存")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_Save(processamento)
        ass = r.cpLackMaterialSub_qlpage("productName", msg[1])
        ass_processamento = jsonpath.jsonpath(ass.json(),
                                              '$..processamento')[0]
        ass_status = jsonpath.jsonpath(ass.json(), '$..status')[0]
        assert ass_processamento == processamento
        assert ass_status == 100

    @pytest.mark.parametrize(
        "processamento",
        testdata["cpLackMaterialSub_EditSave_Data"],
        ids=["编辑质量不合格缺料提报保存", "编辑有货不可用缺料提报保存", "编辑采购缺料提报保存"])
    @allure.feature("缺料提报编辑保存")
    def test_cpLackMaterialSub_EditSave(self, gettokenfixture, processamento):
        s = gettokenfixture
        self.log.info("缺料提报编辑保存")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_EditSave(processamento)
        page = r.cpLackMaterialSub_qlpage("productName",
                                          "3e316193-33d7-4dbe-b161")
        ass_processamento = jsonpath.jsonpath(page.json(),
                                              '$..processamento')[0]
        assert msg.json()["success"] == 1
        assert ass_processamento == processamento

    @pytest.mark.parametrize(
        "processamento",
        testdata["cpLackMaterialSub_EditSave_Data"],
        ids=["编辑质量不合格缺料提报提交", "编辑有货不可用缺料提报提交", "编辑采购缺料提报提交"])
    @allure.feature("缺料提报编辑保存")
    def test_cpLackMaterialSub_EditSave(self, gettokenfixture, processamento):
        s = gettokenfixture
        self.log.info("缺料提报编辑保存")
        r = SRMBase(s)
        msg = r.cpLackMaterialSub_EditSave(processamento)
        page = r.cpLackMaterialSub_qlpage("productName",
                                          "3e316193-33d7-4dbe-b161")
        ass_processamento = jsonpath.jsonpath(page.json(),
                                              '$..processamento')[0]
        assert msg.json()["success"] == 1
        assert ass_processamento == processamento

    @pytest.mark.parametrize("key, value",
                             testdata["lackMaterial_data"],
                             ids=["删除待提交数据", "删除待确认数据"])
    @allure.feature("缺料提报删除")
    def test_lackMaterial(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("缺料提报删除")
        r = SRMBase(s)
        page = r.cpLackMaterialSub_statusPage(key, value)
        self.log.info("查询第一条是:%s" % page.json()["data"]["records"][0])
        lackMaterialSubId = jsonpath.jsonpath(page.json(),
                                              '$..lackMaterialSubId')[0]
        msg = r.lackMaterial(lackMaterialSubId)
        sql = "SELECT STATE FROM CP_LACK_MATERIAL_SUB " \
              "WHERE LACK_MATERIAL_SUB_ID = '%s'" % lackMaterialSubId
        state = Db_Oracle().select(sql)
        assert state["STATE"] == 0

    @pytest.mark.parametrize("key, value",
                             testdata["buyerConfirm_page_Data"],
                             ids=["根据提报号查询", "根据物料号查询"])
    @allure.feature("采购员确认查询")
    def test_buyerConfirm_page(self, gettokenfixture, key, value):
        s = gettokenfixture
        self.log.info("采购员确认查询")
        r = SRMBase(s)
        msg = r.buyerConfirm_page(key, value)
        self.log.info("查询结果是:%s" % msg.json())
        lackMaterialSubNo = jsonpath.jsonpath(msg.json(),
                                              '$..lackMaterialSubNo')[0]
        materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0]
        if key == "lackMaterialSubNo":
            assert lackMaterialSubNo == value
        else:
            assert materialCode == value

    @pytest.mark.parametrize("sysUser, buyerAccount, expect",
                             testdata["buyerCareOf_Data"],
                             ids=["转给admin", "admin转回给zhognzijian"])
    @allure.feature("采购员确认页面转交")
    def test_buyerCareOf(self, gettokenfixture, admintokenfixture, sysUser,
                         buyerAccount, expect):
        s = gettokenfixture
        admin = admintokenfixture
        self.log.info("采购员确认页面转交")
        r = SRMBase(s)
        a = SRMBase(admin)
        try:
            if buyerAccount == "zhongzijian":
                give = r.buyerCareOf(sysUser, buyerAccount)
                print("give:", give.text)
                a_page = a.buyerConfirm_page("lackMaterialSubNo", expect)
                self.log.info("admin查询到结果是:%s" % a_page.json())
                give_lackMaterialSubNo = jsonpath.jsonpath(
                    a_page.json(), '$..lackMaterialSubNo')[0]
                assert give_lackMaterialSubNo == expect
                assert give.json()["success"] == 1
            else:
                give_back = a.buyerCareOf(sysUser, buyerAccount)
                print(give_back.text)
                s_page = r.buyerConfirm_page("lackMaterialSubNo", expect)
                self.log.info("zhongzijian查询到结果是:%s" % s_page.json())
                give_back_lackMaterialSubNo = jsonpath.jsonpath(
                    s_page.json(), '$..lackMaterialSubNo')[0]
                assert give_back_lackMaterialSubNo == expect
                assert give_back.json()["success"] == 1
        except:
            self.log.info("订单或订单顺序异常")
 def __init__(self,driver):
     Base.__init__(self,driver)
     yaml = ReadYaml("./data/element_loc.yaml")
     self.company_notice_more_loc=yaml.analysis_data("index","company_notice_more_loc") # 公司公告【更多】
     self.operation_column_loc=yaml.analysis_data("notice_list","operation_column_loc")  # 操作列
     self.row_titles_loc=yaml.analysis_data("notice_list","row_titles_loc")  #所有文章标题
     self.top_btns_loc=yaml.analysis_data("notice_list","top_btns_loc") #所有置顶按钮
     self.toast_loc = yaml.analysis_data("edit_notice", "toast_loc")  # toast信息
     self. article_rows_loc=yaml.analysis_data("notice_list","article_rows_loc") #列表中的所有行
     self.top_icons_loc=yaml.analysis_data("notice_list","top_icons_loc") #【顶】标签
     self.time_columns_loc=yaml.analysis_data("notice_list","time_columns_loc")  #时间列(包含表头)
     self.refresh_btns_loc=yaml.analysis_data("notice_list","refresh_btns_loc")  #所有【刷新】按钮
     self.delete_btns_loc=yaml.analysis_data("notice_list","delete_btns_loc")  #所有【删除】按钮
     self.notice_count_text=yaml.analysis_data("notice_list","notice_count_text")  #公告记录数文本
     self.confirm_btn_loc=yaml.analysis_data("notice_list","confirm_btn_loc") # 提示消息-【确定】按钮
Example #5
0
import allure
import requests
import pytest
from api.login_method import Login
from common.logger import Log
from common.read_yaml import ReadYaml
testdata = ReadYaml("login_data.yml").get_yaml_data()  #读取数据


@allure.feature('登录测试用例接口')  #测试报告显示测试功能
class Test_login():
    '''测试登录接口'''
    log = Log()

    @pytest.mark.parametrize("username,password,expect",
                             testdata["test_login_data"],
                             ids=[
                                 "正常登录", "密码为空登录", "账号为空登录", "账号错误登录",
                                 "密码错误登录", "账号存在空格登录", "密码存在空格登录",
                                 "账号存在特殊符号登录", "密码存在特殊符号登录", "账号不完整登录",
                                 "密码不完整登录"
                             ])  #参数化测试用例
    @allure.step('账号,密码登录')  #测试报告显示步骤
    @allure.link('http://**********:6009/api/v1/dan_jiekou',
                 name='测试接口')  #测试报告显示链接
    def test_login(self, username, password, expect):
        s = requests.session()  #定义session会话
        self.log.info('------用户登录接口-----')
        shili = Login(s)  #实例化
        msg = shili.login(username, password)
        self.log.info('获取请求结果:%s' % msg.json())
Example #6
0
import sys
import allure
import pytest
from common.logger import Log
from common.read_yaml import ReadYaml

from pymockDemo3_1 import Api_Person_Auth

testdata = ReadYaml("person_auth.yml").get_yaml_data()  #读取参数化的数据


@allure.feature('实名认证')
class Test_person_Auth(object):
    log = Log()

    @allure.title('实名认证')
    #使用parametrize参数化请求参数、状态码和返回信息
    @pytest.mark.parametrize('real_name,id_card,mobile,expect',
                             testdata['person_auth'],
                             ids=['正确传入参数', '全部参数为空', '姓名为空', '姓名错误'])
    def test_person_auth(self, mocker, real_name, id_card, mobile, expect):
        self.log.info('%s,%s' %
                      ((sys._getframe().f_code.co_name, '------认证接口-----')))
        shili = Api_Person_Auth()  # 实例化
        #方法一
        shili.api_person_auth = mocker.patch.object(
            Api_Person_Auth,
            'api_person_auth',
            return_value={'resultcode': expect['resultcode']})  #引用参数化状态码
        #当传入side_effect时,return_value就会失效,当调用真实的认证方法时,就会使用真实的认证方法,从而达到真实的测试如下:
        # shili.api_person_auth = mocker.patch.object(Api_Person_Auth, 'api_person_auth',
Example #7
0
class TestSRM:
    """测试登录接口"""
    log = Log()
    testdata = ReadYaml("case_data.yml").get_yaml_data()  # 读取数据

    @pytest.mark.parametrize("username,pwd,expect",
                             testdata["test_login_data"],
                             ids=[
                                 "正常登录",
                                 "密码为空登录",
                                 "账号为空登录",
                                 "账号错误登录",
                                 "密码错误登录",
                                 "账号存在空格登录",
                                 "账号存在特殊符号登录",
                                 "密码存在特殊符号登录",
                             ])  # 参数化测试用例
    @allure.feature('登录接口')  # 测试报告显示测试功能
    @allure.step('账号,密码登录')  # 测试报告显示步骤
    @allure.link('https://qupuat.quanyou.com.cn/', name='QUP登录接口')  # 测试报告显示链接
    def test_login(self, username, pwd, expect):  # 登录接口测试
        s = requests.session()  # 定义session会话
        self.log.info('------用户登录接口-----')
        shili = SRMBase(s)  # 实例化
        msg = shili.login(username, pwd)
        self.log.info('获取请求结果:%s' % msg.json())
        # print(msg.json())
        if msg.status_code == 200:
            assert msg.json()["license"] == expect['license']
        else:
            assert msg.json()["msg"] == expect['msg']

    '''用户新增接口'''
    # @pytest.mark.skip(reason="环境无法连接数据库")
    @pytest.mark.parametrize("username,phone,expect",
                             testdata["sysuser_data"],
                             ids=["正常新增用户", "正常新增用户二"])
    @allure.feature('用户新增接口')  # 测试报告显示测试功能
    def test_sysuser(self, sysUser_sql, gettokenfixture, username, phone,
                     expect):  # 用户新增接口测试
        s = gettokenfixture
        self.log.info('-----用户新增接口-----')
        shili = SRMBase(s)
        msg = shili.sysuser(username, phone)
        ass = shili.sysUser_page("userName", username)
        print("查询结果是{}".format(ass.text))
        ass_phone = jsonpath.jsonpath(ass.json(), '$..phone')[0]
        self.log.info('获取请求结果:%s' % msg.json())
        assert msg.json()["success"] == expect["success"]
        assert ass_phone == phone

    '''用户查询接口'''

    @pytest.mark.parametrize("key,value,expect",
                             testdata["sysUser_page_data"],
                             ids=["查询手机号"])
    @allure.feature('用户查询')  # 测试报告显示测试功能
    def test_sysUser_page(self, gettokenfixture, key, value,
                          expect):  #用户管理查询接口测试
        s = gettokenfixture
        self.log.info('-----用户查询接口-----')
        r = SRMBase(s)
        msg = r.sysUser_page(key, value)
        self.log.info('获取请求结果:%s' % msg.json())
        result = jsonpath.jsonpath(msg.json(), '$..phone')[0]
        assert result == expect

    '''用户编辑接口'''

    @pytest.mark.parametrize("username,phone,role,expect,expect1,expect2",
                             testdata["sysuser_put_data"],
                             ids=["正常编辑用户", "编辑输入重复手机号", "编辑角色和名称"])
    @allure.feature('用户编辑接口')  # 测试报告显示测试功能
    def test_SysUser_put(self, gettokenfixture, username, phone, role, expect,
                         expect1, expect2):
        s = gettokenfixture
        self.log.info('-----用户编辑接口-----')
        r = SRMBase(s)
        putmsg = r.SysUser_put(username, phone, role)
        self.log.info('获取请求结果:{}'.format(putmsg.json()))
        selmsg = r.sysUser_page("phone", "15555555552")
        self.log.info('获取请求结果:{}'.format(selmsg.json()))
        result = jsonpath.jsonpath(selmsg.json(), '$..phone')[0]
        result1 = jsonpath.jsonpath(selmsg.json(), '$..userName')[0]
        result2 = jsonpath.jsonpath(selmsg.json(), '$..roleNames')[0]
        print(result2)
        assert result == expect
        assert result1 == expect1
        assert result2 == expect2

    '''用户启停接口'''

    @pytest.mark.parametrize("state,expect",
                             testdata["sysuser_state_data"],
                             ids=["停用用户", "启用用户"])
    @allure.feature('用户启停接口')  # 测试报告显示测试功能
    def test_SysUser_state(self, gettokenfixture, state, expect):
        s = gettokenfixture
        url = os.environ["host"] + "/srm/api/v1/sysUser/state"
        data = {"account": 70061501, "state": state}
        msg = s.put(url, data=data)
        sta = SRMBase(s).sysUser_page("vendorAccount", "70061501")
        sta.msg = jsonpath.jsonpath(sta.json(), '$..state')[0]
        assert sta.msg == expect
class TestSrmVendor:
    log = Log()
    testdata = ReadYaml("vendor_data.yml").get_yaml_data()

    @pytest.mark.prod
    @pytest.mark.parametrize("key,value,expect",
                             testdata["vendorMasterData_page_data"],
                             ids=["供应商编码", "数据状态"])
    @allure.feature('供应商主数据查询')  # 测试报告显示测试功能
    def test_vendorMasterData_page(self, gettokenfixture, key, value, expect):
        s = gettokenfixture
        self.log.info("----供应商主数据查询接口----")
        r = Srmvendor(s)
        msg = r.vendorMasterData_page(key, value)
        self.log.info("获取请求结果: %s" % msg.json())
        if key == "vendorCode":
            result = jsonpath.jsonpath(msg.json(), '$..vendorCode')[0]
            assert result == expect
        else:
            result = jsonpath.jsonpath(msg.json(), '$..state')[0]
            assert result == 1

    @pytest.mark.parametrize("key,value,expect",
                             testdata["vendorQualityQuestion_page_data"],
                             ids=["事故单号", "查询工厂编码"])
    @allure.feature('新建质量问题查询')  # 测试报告显示测试功能
    def test_vendorQualityQuestion_page(self, gettokenfixture, key, value,
                                        expect):
        s = gettokenfixture
        self.log.info("----新建质量问题查询接口----")
        r = Srmvendor(s)
        msg = r.vendorQualityQuestion_page(key, value)
        self.log.info("获取请求结果: %s" % msg.json())
        if key == "qualityTroubleNo":
            result = jsonpath.jsonpath(msg.json(), '$..qualityTroubleNo')[0]
            assert result == expect
        else:
            result = jsonpath.jsonpath(msg.json(), '$..plantCode')[0]
            assert result == "6199"

    @pytest.mark.parametrize("purchasePerson,expect",
                             testdata["vendorQualityQuestion_save_data"],
                             ids=["保存数据采购员为吴茜", "保存数据采购员为钟子鉴"])
    @allure.feature('新增质量问题保存')
    def test_vendorQualityQuestion_save(self, gettokenfixture, purchasePerson,
                                        expect):
        s = gettokenfixture
        self.log.info("-----新增质量问题保存-----")
        r = Srmvendor(s)
        msg = r.vendorQualityQuestion_save(purchasePerson)
        result = msg[0]
        self.log.info("获取请求结果{}".format(result.json()))
        assert result.json()["success"] == 1
        assert result.status_code == 200

    @pytest.mark.parametrize("key,value,expect",
                             testdata["vendorBankInfoManage_page_data"],
                             ids=["供应商编码对应银行信息", "查询银行状态已完善"])
    @allure.feature('银行信息管理数据查询')  # 测试报告显示测试功能
    def test_vendorBankInfoManage_page(self, gettokenfixture, key, value,
                                       expect):
        s = gettokenfixture
        self.log.info("----银行信息管理数据查询接口----")
        r = Srmvendor(s)
        msg = r.vendorBankInfoManage_page(key, value)
        self.log.info("获取请求结果: %s" % msg.json())
        if key == "vendorCode":
            result = jsonpath.jsonpath(msg.json(), '$..vendorCode')[0]
            assert result == expect
        else:
            result = jsonpath.jsonpath(msg.json(), '$..bankStatus')[0]
            assert result == 300

    @pytest.mark.parametrize("purchasePerson",
                             testdata["vendorQualityQuestion_add_data"],
                             ids=["新建质量问题提交采购员1", "新建质量问题提交采购员2"])
    @allure.feature('新建质量问题提交')
    def test_vendorQualityQuestion_add(self, gettokenfixture, purchasePerson):
        s = gettokenfixture
        self.log.info("----新建质量问题提交接口----")
        r = Srmvendor(s)
        msg = r.vendorQualityQuestion_add(purchasePerson)
        result = msg[0]
        self.log.info("获取请求结果{}".format(result.json()))
        assert result.json()["success"] == 1
        assert result.status_code == 200

    @pytest.mark.parametrize("source, status, s1_expect, s2_expect",
                             testdata["vendorImport_data"],
                             ids=[
                                 "供应商引入查询自主注册", "供应商引入查询引入新增", "供应商引入查询潜在重新申请",
                                 "供应商引入查询数据迁移", "供应商引入查询待提交", "供应商引入查询开发员已退回",
                                 "供应商引入查询开发员待确认", "供应商引入查询采购领导退回",
                                 "供应商引入查询开发人员待提交", "供应商引入查询采购领导待审核",
                                 "供应商引入查询未通过", "供应商引入查询已建档"
                             ])
    @allure.feature("供应商引入查询接口")
    def test_vendorImport(self, gettokenfixture, source, status, s1_expect,
                          s2_expect):
        s = gettokenfixture
        self.log.info("供应商引入状态查询接口")
        r = Srmvendor(s)
        msg = r.vendorImport(source, status)
        self.log.info("获取结果是:%s" % msg.json())
        ass_s1 = jsonpath.jsonpath(msg.json(), '$..source')[0]
        ass_s2 = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_s1)
        ass2 = repr(ass_s2)
        assert ass1 in s1_expect
        assert ass2 in s2_expect

    @pytest.mark.parametrize("state, expect",
                             testdata["vendorMasterData_master_page"],
                             ids=["查询供应商主数据数据状态正常", "查询供应商主数据数据状态冻结"])
    @allure.feature("供应商主数据数据状态查询")
    def test_vendorMasterData_master_page(self, gettokenfixture, state,
                                          expect):
        s = gettokenfixture
        self.log.info("供应商主数据数据状态查询")
        r = Srmvendor(s)
        msg = r.vendorMasterData_master_page(state)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..state')[0]
        assert a_msg == expect

    @pytest.mark.parametrize("status, expect",
                             testdata["vendorChangeInfo_page"],
                             ids=[
                                 "供应商信息变更管理查询待提交", "供应商信息变更管理查询已退回",
                                 "供应商信息变更管理查询待审核", "供应商信息变更管理查询开发员待确认",
                                 "供应商信息变更管理查询完成"
                             ])
    @allure.feature("供应商信息变更管理状态")
    def test_vendorChangeInfo_page(self, gettokenfixture, status, expect):
        s = gettokenfixture
        self.log.info("查询供应商信息变更管理状态")
        r = Srmvendor(s)
        msg = r.vendorChangeInfo_page(status)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..status')[0]
        assert a_msg == expect

    @allure.feature('供应商主数据导出接口')
    def test_vendorMasterData_reportExcel(self, gettokenfixture):
        s = gettokenfixture
        r = Srmvendor(s)
        self.log.info("---供应商主数据导出---")
        msg = r.vendorMasterData_reportExcel()
        assert msg.status_code == 200

    @allure.feature('银行信息管理导出接口')
    def test_vendorBankInfoManage_exportExcle(self, gettokenfixture):
        s = gettokenfixture
        r = Srmvendor(s)
        self.log.info("---银行信息管理导出---")
        msg = r.vendorBankInfoManage_exportExcle()
        assert msg.status_code == 200

    @allure.feature('质量问题管理导出数据接口')
    def test_vendorQualityQuestion_export(self, gettokenfixture):
        s = gettokenfixture
        r = Srmvendor(s)
        self.log.info("---质量问题管理数据导出---")
        msg = r.vendorQualityQuestion_export()
        assert msg.status_code == 200

    @pytest.mark.parametrize(
        "bankStatus, expect",
        testdata["vendorBankInfoManage_page1"],
        ids=["银行信息待完善", "银行信息待提交", "银行信息已退回", "银行信息待审核", "银行信息已完善"])
    @allure.feature("银行信息管理状态")
    def test_vendorBankInfoManage_page1(self, gettokenfixture, bankStatus,
                                        expect):
        s = gettokenfixture
        self.log.info("查询银行信息管理状态")
        r = Srmvendor(s)
        msg = r.vendorBankInfoManage_page1(bankStatus)
        self.log.info("获取的结果是:%s" % msg.json())
        a_msg = jsonpath.jsonpath(msg.json(), '$..bankStatus')[0]
        assert a_msg == expect

    @pytest.mark.parametrize("state, status, s1_expect, s2_expect",
                             testdata["vendorBankInfoManage_detail_page"],
                             ids=[
                                 "供应商银行明细信息查询数据状态正常", "供应商银行明细信息查询数据状态冻结",
                                 "供应商银行明细信息查询审核状态待完善", "供应商银行明细信息查询审核状态待提交",
                                 "供应商银行明细信息查询审核状态已退回", "供应商银行明细信息查询审核状态待审核",
                                 "供应商银行明细信息查询审核状态已完善"
                             ])
    @allure.feature("供应商银行明细信息状态查询接口")
    def test_vendorBankInfoManage_detail_page(self, gettokenfixture, state,
                                              status, s1_expect, s2_expect):
        s = gettokenfixture
        self.log.info("供应商银行明细信息状态查询")
        r = Srmvendor(s)
        msg = r.vendorBankInfoManage_detail_page(state, status)
        self.log.info("获取结果是:%s" % msg.json())
        ass_s1 = jsonpath.jsonpath(msg.json(), '$..state')[0]
        ass_s2 = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_s1)
        ass2 = repr(ass_s2)
        assert ass1 in s1_expect
        assert ass2 in s2_expect

    @pytest.mark.parametrize("troubleType, status, t_expect, s_expect",
                             testdata["vendorQualityQuestion_page1"],
                             ids=[
                                 "新建质量问题查询质量事故", "新建质量问题查询生产事故",
                                 "新建质量问题查询品管-待提交", "新建质量问题查询已退回", "新建质量问题查询待审核"
                             ])
    @allure.feature("新建质量问题事故类型和状态查询接口")
    def test_vendorQualityQuestion_page1(self, gettokenfixture, troubleType,
                                         status, t_expect, s_expect):
        s = gettokenfixture
        self.log.info("新建质量问题事故类型和状态查询")
        r = Srmvendor(s)
        msg = r.vendorQualityQuestion_page1(troubleType, status)
        self.log.info("获取结果是:%s" % msg.json())
        ass_t = jsonpath.jsonpath(msg.json(), '$..troubleType')[0]
        ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_t)
        ass2 = repr(ass_s)
        assert ass1 in t_expect
        assert ass2 in s_expect

    @pytest.mark.parametrize("troubleType, status, t_expect, s_expect",
                             testdata["vendorQualityQuestion_page2"],
                             ids=[
                                 "质量问题管理查询质量事故", "质量问题管理查询生产事故",
                                 "质量问题管理查询品管-待提交", "质量问题管理查询待处理",
                                 "质量问题管理查询已退回", "质量问题管理查询待审核", "质量问题管理查询审核退回",
                                 "质量问题管理查询待确认", "质量问题管理查询待协商", "质量问题管理查询已完成"
                             ])
    @allure.feature("质量问题管理事故类型和状态查询接口")
    def test_vendorQualityQuestion_page2(self, gettokenfixture, troubleType,
                                         status, t_expect, s_expect):
        s = gettokenfixture
        self.log.info("质量问题管理事故类型和状态查询")
        r = Srmvendor(s)
        msg = r.vendorQualityQuestion_page2(troubleType, status)
        self.log.info("获取结果是:%s" % msg.json())
        ass_t = jsonpath.jsonpath(msg.json(), '$..troubleType')[0]
        ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0]
        ass1 = repr(ass_t)
        ass2 = repr(ass_s)
        assert ass1 in t_expect
        assert ass2 in s_expect
 def __init__(self, driver):
     Base.__init__(self, driver)
     yaml = ReadYaml("./data/element_loc.yaml")
     self.setting_btn_loc = yaml.analysis_data("index",
                                               "setting_btn_loc")  # 【设置】按钮
Example #10
0
 def __init__(self):
     self.config = ReadYaml(get_configf_path()).get_data_one()