test_Q&A_center.py 3.98 KB
import json

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


class QACenter(ATDDCase):

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

    def setUp(self):
        pass

    # 问答中心-提问
    def test_question(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "question",
            "remark": "问答中心-提问",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #提问次数(循环类型) 全局
                    "value": 2
                 }
            ]
        }

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


    # 新闻资讯-回答
    def test_answered(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "answered",
            "remark": "新闻资讯-回答",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": 2
                },
                {
                    "triggerKey": "answered_business_number",  # 回答提问个数 (循环类型) 全局
                    "value": 2
                }
            ]
        }

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


    # 新闻资讯-被采纳最佳答案
    def test_best_answered(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "best_answered",
            "remark": "新闻资讯-被采纳最佳答案",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": 2
                }
            ]
        }

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


    # 新闻资讯-提问被回答
    def test_question_was_answered(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "question_was_answered",
            "remark": "新闻资讯-提问被回答",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数 (循环类型) 全局
                    "value": 2
                },
                {
                    "triggerKey": "was_answered_number",  # 被回答个数(循环类型) 全局
                    "value": 2
                }
            ]
        }

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