test_jobLevel.py 2.7 KB
'''
Author: jipeigong 2017年7月19日17:53:38
'''

from atdd.PcApiTest import PcApiTest
from tests.Integral.IntergalPC.test_Integral import Integral


class jobLevel(PcApiTest):

    #登录
    def setUp(self):
        self.do_login(self.host, self.mobile, self.psw, self.domain)

    # 获取企业计算等级规则明细——岗位
    def test_levelList_job(self):
        interfaceUrl = "/Integral/Apicp/Level/List"
        data = {
            "page": 1,
            "limit": 10,
            "eilType": "1",  # 岗位
            "pageNum": 1,
            "pageSize": 999
        }
        result = self.PcApiTest(interfaceUrl, data)
        print(result)
        return result


    #获取某岗位的岗位ID,等级ID
    def get_levelInfo(self):
        resultLevelList = self.test_levelList_job()
        levelList = resultLevelList['result']['list']
        for i in range(len(levelList)):
            if (levelList[i]['objName'] == "季培红岗位"):
                return levelList[i]['eilId'], levelList[i]['eilObjId']
        else:
            print("不存在“季培红岗位”!")


    # 保存计算等级规则-岗位
    def test_levelSave(self):
        interfaceUrl =  "/Integral/Apicp/Level/Save"

        # 获取icon的ID和URL
        uploadAtta = Integral().test_UploadAtta()
        icon = uploadAtta['result']['atId']
        iconUrl = uploadAtta['result']['atAttachment']

        eilId = self.get_levelInfo()[0]
        eilObjId = self.get_levelInfo()[1]

        data = self.parse_array("eilLevelSetting", [
            {
                "name": "LV1",
                "max": 100,
                "icon": icon,
                "iconUrl": iconUrl,
                "iconType": "2"
            },
            {
                "name": "LV10",
                "max": -1,
                "icon": icon,
                "iconUrl": iconUrl,
                "iconType": "2"
            }])

        data["eilId"] = eilId  # 岗位等级ID
        data["eilType"] = "1"
        data["eilObjId"] = eilObjId  # 季培红岗位ID

        print(data)

        result = self.PcApiTest(interfaceUrl,data)
        print(result)
        return result

    # # 删除岗位等级-删除最后一个岗位等级
    # def test_delete_job(self):
    #     interfaceUrl = "/Integral/Apicp/Level/Delete"
    #     resultJobLevel = self.test_levelList_job()
    #     listJobLevel = resultJobLevel['result']['list']
    #     self.assertNotEquals(1, len(listJobLevel))
    #     lastJobEIlId = listJobLevel[len(listJobLevel) - 1]['eilId']  # 最后一个岗位的等级ID
    #
    #     data = {
    #         "eilId": lastJobEIlId
    #     }
    #     result = self.PcApiTest(interfaceUrl, data)
    #     print(result)
    #     return result