test_news_center.py 4.64 KB
import json

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


class NewsCenter(ATDDCase):

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

    def setUp(self):
        pass

    # 新闻资讯-分享
    def test_shared(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "shared",
            "remark": "新闻资讯-分享",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "shared_num",  #次数(循环类型) 全局
                    "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_comment(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "comment",
            "remark": "新闻资讯-评论",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "number",  #次数(循环类型) 全局
                    "value": 2
                },
                {
                    "triggerKey": "business_num",  # 评论新闻篇数 (循环类型) 全局
                    "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_like(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "like",
            "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_read(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "read",
            "remark": "新闻资讯-阅读",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "complete",  #完成 (枚举类型) 单个
                    "value": 2
                },
                {
                    "triggerKey": "complete_num",  # 完成阅读新闻篇数(循环类型) 全局
                    "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_collect(self):
        print(self.triggerKeyDict)
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "collect",
            "remark": "新闻资讯-收藏",
            "businessId": "55",
            "triggerTypes": [
                {
                    "triggerKey": "collect_num",  #次数(循环类型) 全局
                    "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')