test_abnormal_colleague_circle.py 4.04 KB
import json
import random

from atdd.ATDDCase import ATDDCase
from tests.Integral.publicMethods import PCpublicMethods


class ColleagueCircle(ATDDCase):

    global list
    url = ATDDCase().uc_host + '/a/' + ATDDCase().domain + '/' + ATDDCase().app + "/qy/integral/change"
    businessKey = "colleague_circle"
    triggerKeyDict = PCpublicMethods.PCpublicMethods().getTriggerKey(businessKey)
    triggerValueDict = PCpublicMethods.PCpublicMethods().getTriggerValue(businessKey)
    dictLimitConditions = PCpublicMethods.PCpublicMethods().getLimitConditions(businessKey)

    message = "不满足加分条件,原因: 规则验证不通过或是规则中设定的加分值为0"


    def setUp(self):
        pass

    #同事圈-评论话题
    def test_comment(self):
        # print(self.triggerKeyDict)
        # print(self.triggerValueDict)

        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "comment",
            "remark": "同事圈-评论话题",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": int(self.triggerValueDict['comment-number'][0]['condition'])-1   # 没达到触发条件值
                },
                {
                    "triggerKey": "comment_business_num", #评论个数(循环类型) 全局
                    "value": self.triggerValueDict['comment-comment_business_num'][0]['condition']
                }]
        }

        result = self.post(self.url, json.dumps(data), headers=self.header_json)
        code = result.json()['code']

        self.assertNotEquals(code, 'INTEGRAL_RULE_NDAYOT_OPEN')  # 积分策略没有启用
        self.assertEquals(code,'SUCCESS')

        message = result.json()['data'][0]['message']
        self.assertEquals(message, self.message)



    #同事圈-话题被评论
    def test_was_comment(self):

        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "was_comment",
            "remark": "同事圈-话题被评论",
            "businessId": "xx",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": int(self.triggerValueDict['was_comment-number'][0]['condition'])-1 # 没达到触发条件值
                },
                {
                    "triggerKey": "was_comment_num", #评论个数(循环类型) 全局
                    "value": int(self.triggerValueDict['was_comment-was_comment_num'][0]['condition'])+1 # 超过触发条件值
                }
            ]
        }

        result = self.post(self.url, json.dumps(data), headers=self.header_json)
        code = result.json()['code']

        self.assertNotEquals(code, 'INTEGRAL_RULE_NDAYOT_OPEN')  # 积分策略没有启用
        self.assertEquals(code, 'SUCCESS')

        self.assertEquals(result.json()['data'][0]['message'], self.message)
        self.assertEquals(result.json()['data'][1]['message'], self.message)


    #同事圈-发表话题  触发条件值的倍数
    def test_push(self):
        n = random.randint(1, 999)
        print(n)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "push",
            "remark": "同事圈-发表话题",
            "businessId": "7",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": int(self.triggerValueDict['push-number'][0]['condition'])*n
                 }
            ]
        }

        result = self.post(self.url, json.dumps(data), headers=self.header_json)
        print(result.json())
        code = result.json()['code']
        self.assertNotEquals(code, 'INTEGRAL_RULE_NDAYOT_OPEN')  # 积分策略没有启用
        self.assertEquals(code, 'SUCCESS')
        self.assertEquals(result.json()['data'][0]['message'], '')