test_searchByOther.py 6.59 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/8/10 17:33
# @Author  : Ljq
# @File    : test_searchByOther.py
# @Software: PyCharm

"""
进门单列表其他他查询条件
"""

import json
import unittest
from commons.scripts.readConf import rC
from commons.api import zcApi as zcA
from commons.basic import getLookupList as gLL
from commons import ConfigDB as CoDB
from commons.MySession import my
from commons.api.entranceFeeBillList import entranceFeeBillList as eFBL
import time,random

class test_listPage(unittest.TestCase):
    """进门单列表:attr进门单属性查询测试"""
    def setUp(self) -> None:
        pass

    def tearDown(self) -> None:
        pass


    @classmethod
    def setUpClass(cls) -> None:
        cls.gatewayHost = rC.returnOptionsItems("host", "gatewayHost")
        cls.jmsfHost = rC.returnOptionsItems("host", "jmsfHost")
        cls.ic = rC.returnOptionsItems("testInfo", "cardNumRe")
        carTypeList = gLL.get_LookupList(host=cls.jmsfHost,providerName="车型").json()[1:]
        categoryList = gLL.get_LookupList(host=cls.jmsfHost, providerName="货物品类").json()[1:]
        authDepartmentList = zcA.get_dep(cls.gatewayHost).json()["data"]
        entranceFeeBillTypeList = gLL.get_LookupList(host=cls.jmsfHost, providerName="称重类型").json()[1:]
        entranceFeeBillStateList = gLL.get_LookupList(host=cls.jmsfHost, providerName="状态").json()[1:]
        tradeTypeList = gLL.get_LookupList(host=cls.jmsfHost, providerName="交易类型").json()[1:]
        cls.carType = random.sample(carTypeList, 1)[0]
        cls.category = random.sample(categoryList, 1)[0]
        cls.authDepartment = random.sample(authDepartmentList, 1)[0]
        cls.entranceFeeBillType = random.sample(entranceFeeBillTypeList, 1)[0]
        cls.entranceFeeBillState = random.sample(entranceFeeBillStateList, 1)[0]
        cls.tradeType = random.sample(tradeTypeList, 1)[0]

    @classmethod
    def tearDownClass(cls) -> None:
        pass

    def test_searchByCardTepy(self):
        """进门单列表-查询:收费单号查询测试"""
        print(self.carType)
        cre_res = zcA.create_jmsf(host=self.gatewayHost,carTypeName=self.carType["text"])
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,carTypeId=self.carType["value"])
        print(resListPage.json())
        carTypeList=list(set([i["carTypeName"] for i in resListPage.json()["rows"]]))
        assert resListPage.json()["rows"][0]["number"] == number,"车型查询失败查询失败"
        assert len(carTypeList) == 1,"车型查询失败查询失败"
        assert self.carType["text"]==carTypeList[0],"车型查询失败查询失败"

    def test_searchBycategory(self):
        """进门单列表-查询:收费单号查询测试"""
        goods="雪莲果"
        categoryId = "14436"
        cre_res = zcA.create_jmsf(host=self.gatewayHost,keyword=goods)
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,categoryId=categoryId)
        print(resListPage.json())
        assert resListPage.json()["rows"][0]["number"] == number,"车型查询失败查询失败"

    def test_searchByProductName(self):
        """进门单列表-查询:收费单号查询测试"""
        productName = "蔬菜"
        productId = gLL.get_product(self.jmsfHost,productName=productName).json()["data"][0]["id"]
        print(productId)
        cre_res = zcA.create_jmsf(host=self.gatewayHost,keyword=productName)
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,productName=productName,productId=productId)
        print(resListPage.json())
        productNameList=list(set([i["productName"] for i in resListPage.json()["rows"]]))
        assert resListPage.json()["rows"][0]["number"] == number,"车型查询失败查询失败"
        assert len(productNameList) == 1,"车型查询失败查询失败"
        assert productName==productNameList[0],"车型查询失败查询失败"

    def test_searchByDepartment(self):
        """进门单列表-查询:收费单号查询测试"""
        print(self.authDepartment)
        print(self.authDepartment["name"])
        cre_res = zcA.create_jmsf(host=self.gatewayHost,depName=self.authDepartment["name"])
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,dep=self.authDepartment["id"])
        # print(resListPage.json())
        depNameList=list(set([i["depName"] for i in resListPage.json()["rows"]]))
        assert resListPage.json()["rows"][0]["number"] == number,"车型查询失败查询失败"
        assert len(depNameList) == 1,"车型查询失败查询失败"
        assert self.authDepartment["name"]==depNameList[0],"车型查询失败查询失败"

    def test_searchByBillType(self):
        """进门单列表-查询:收费单号查询测试"""
        resListPage = eFBL.listPage(host=self.jmsfHost,type="1")
        print(resListPage.json())
        resList=list(set([i["type"] for i in resListPage.json()["rows"]]))
        assert len(resList) == 1,"车型查询失败查询失败"
        assert "整车"==resList[0],"车型查询失败查询失败"

    def test_searchByStatus(self):
        """进门单列表-查询:收费单号查询测试"""
        status = "4"
        cre_res = zcA.create_jmsf(host=self.gatewayHost,carTypeName=self.carType["text"])
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,status=status)
        print(resListPage.json())
        statusList=list(set([i["status"] for i in resListPage.json()["rows"]]))
        assert resListPage.json()["rows"][0]["number"] != number,"车型查询失败查询失败"
        assert len(statusList) == 1,"车型查询失败查询失败"
        assert "已缴费"==statusList[0],"车型查询失败查询失败"

    def test_searchByTradeType(self):
        """进门单列表-查询:收费单号查询测试"""
        print(self.tradeType)
        cre_res = zcA.create_jmsf(host=self.gatewayHost,transactionName=self.tradeType["text"])
        number = cre_res.json()["data"]["number"]
        resListPage = eFBL.listPage(host=self.jmsfHost,tradeTypeId=self.tradeType["value"])
        print(resListPage.json())
        carTypeList=list(set([i["tradeTypeName"] for i in resListPage.json()["rows"]]))
        assert resListPage.json()["rows"][0]["number"] == number,"车型查询失败查询失败"
        assert len(carTypeList) == 1,"车型查询失败查询失败"
        assert self.tradeType["text"]==carTypeList[0],"车型查询失败查询失败"

    """
    三个时间查询暂不涉及
    """