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

from atdd.MobileApiTest import MobileApiTest
from tests.Integral.publicMethods import PCpublicMethods
from tests.Integral.IntergralAPP.test_getDepartments import GetDepartments


class CurrentMemberRanking(MobileApiTest):

    interfaceUrl = "/Integral/Api/Integral/Ranking"

    # 获取岗位ID和角色ID
    def getJobID_RoleID(self):
        # 获取小红红的积分信息,从积分信息中获取岗位名称和角色名称
        result = PCpublicMethods.PCpublicMethods().getMemberInfo("小红红")
        memberInfo = result['result']['list'][0]

        jobName = memberInfo['memJob']
        roleName = memberInfo['memRole']

        jobId = PCpublicMethods.PCpublicMethods().getJobID(jobName)
        roleId = PCpublicMethods.PCpublicMethods().getRoleID(roleName)

        return jobId, roleId

    def setUp(self):
        self.do_login()


    #积分排名->参数为空
    def test_ranking_none(self):
        result = self.MobileApiTest(self.interfaceUrl)
        print(result)
        return result

    #积分排名->总排行
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_all(self):
        data = {
            "ranking_type": 1
        }
        result = self.MobileApiTest(self.interfaceUrl,data)
        print(result)
        return result

    # 积分排名->日排行
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_day(self):
        data = {
            "ranking_type": 2
        }
        result = self.MobileApiTest(self.interfaceUrl, data)
        print(result)
        return result

    # 积分排名->周排行
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_week(self):
        data = {
            "ranking_type": 3
        }
        result = self.MobileApiTest(self.interfaceUrl, data)
        print(result)
        return result

    # 积分排名->月排行
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_month(self):
        data = {
            "ranking_type": 4
        }
        result = self.MobileApiTest(self.interfaceUrl, data)
        print(result)
        return result


    #传岗位ID和角色ID
    def test_ranking_jobId(self):

        jobId = self.getJobID_RoleID()[0]
        roleId = self.getJobID_RoleID()[1]

        data = {
            "dp_id": -1,
            "job_id": jobId,
            "role_id": roleId,
            "ranking_type": 1  #总排行
        }
        result = self.MobileApiTest(self.interfaceUrl,data)
        print(result)


    #该员工所有上级部门的排名->总排名
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_dpId_all(self):

        dpIdList = GetDepartments().member_dpID()   #部门ID list

        for i in range(len(dpIdList)):
            data = {
                "dp_id": dpIdList[i],
                "ranking_type": 1
            }
            result = self.MobileApiTest(self.interfaceUrl,data)
            print(result)

    #该员工所有上级部门的排名->日排名
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_dpId_day(self):

        dpIdList = GetDepartments().member_dpID()   #部门ID list

        for i in range(len(dpIdList)):
            data = {
                "dp_id": dpIdList[i],
                "ranking_type": 2
            }
            result = self.MobileApiTest(self.interfaceUrl,data)
            print(result)

    #该员工所有上级部门的排名->周排名
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_dpId_week(self):

        dpIdList = GetDepartments().member_dpID()   #部门ID list

        for i in range(len(dpIdList)):
            data = {
                "dp_id": dpIdList[i],
                "ranking_type": 3
            }
            result = self.MobileApiTest(self.interfaceUrl,data)
            print(result)

    #该员工所有上级部门的排名->月排名
    # ranking_type: 1-总排行 2-日排行 3-周排行 4-月排行
    def test_ranking_dpId_month(self):

        dpIdList = GetDepartments().member_dpID()   #部门ID list

        for i in range(len(dpIdList)):
            data = {
                "dp_id": dpIdList[i],
                "ranking_type": 4
            }
            result = self.MobileApiTest(self.interfaceUrl,data)
            print(result)