test_Get_level_rule_details.py 2.68 KB
import unittest
from atdd.PcApiTest import PcApiTest
import os

# 获取企业计算等级规则明细
class Getleveldetail(PcApiTest):
    def setUp(self):
        user = self.do_login('https://dengta.vchangyi.com', '13818801804', '123123',
                             domain='wx5019b9c455ea9c81')

    # 无参数>>提示计算类型不能为空
    def test_detail_all(self):
        url = self.host + "/" + self.domain + "/Integral/Apicp/Level/List"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        data = {
        }
        r = self.post(url=url, headers=headers, data=data)
        print(r.text)
        data = r.json()
        print(self.host + '/' + self.domain + '/Integral/Apicp/Level/GetDefaultLevel')
        self.assertEqual(2074050, data["errcode"], msg=data["errcode"])
        self.assertEqual("积分等级计算类型不能为空", data["errmsg"], msg=data["errmsg"])

    # 积分等级计算类型:默认
    def test_detail_default(self):
        url = self.host + "/" + self.domain + "/Integral/Apicp/Level/List"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        data = {
            "eilType": 0
        }
        r = self.post(url=url, headers=headers, data=data)
        print(r.text)
        data = r.json()
        print(self.host + '/' + self.domain + '/Integral/Apicp/Level/GetDefaultLevel')
        self.assertEqual(0, data["errcode"], msg=data["errcode"])
        self.assertEqual("ok", data["errmsg"], msg=data["errmsg"])

    # 积分等级计算类型:按岗位
    def test_detail_job(self):
        url = self.host + "/" + self.domain + "/Integral/Apicp/Level/List"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        filepath = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) + '/Integral/data/parameter/csh.txt'
        with open(filepath, 'r') as r:
            eliType = r.readlines()[0]
        data = {
            "eilType": eliType
        }

        r = self.post(url, headers=headers, data=data)
        print(r.text)


    # 积分等级计算类型:按角色
    def test_detail_role(self):
        url = self.host + "/" + self.domain + "/Integral/Apicp/Level/List"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        data = {
            "eilType": 2
        }
        r = self.post(url=url, headers=headers, data=data)
        print(r.text)
        data = r.json()
        print(self.host + '/' + self.domain + '/Integral/Apicp/Level/GetDefaultLevel')
        self.assertEqual(0, data["errcode"], msg=data["errcode"])
        self.assertEqual("ok", data["errmsg"], msg=data["errmsg"])


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