test_course_center.py 10.9 KB
import json

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


class CourseCenter(ATDDCase):

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

    def setUp(self):
        pass

    # 课程中心-单课程学习
    def test_one_learning(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "one_learning",
            "businessId": "2",
            "triggerTypes": [

                {
                    "triggerKey": "complete",  # 完成(枚举类型)单个
                    "value": 2,
                    "remark": "课程中心-单课程学习_完成(枚举类型)单个"
                },
                {
                    "triggerKey": "number",  # 完成单课程数(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-单课程学习_成单课程数(循环类型)全局",
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-单课程测评
    def test_one_evaluation(self):
        print(self.triggerKeyDict)
        print("\n")
        print(self.triggerValueDict)
        print("\n")
        data = {
            "miType": "mi_type1",
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "one_evaluation",
            "businessId": "111",
            "triggerTypes": [
                {
                    "triggerKey": "pass",  # 通过(枚举类型)单个
                    "value": self.triggerValueDict['one_evaluation-pass'][0]['condition'],
                    "remark": "课程中心-单课程测评"
                },
                {
                    "triggerKey": "pass_rate",  # 通过题数百分比(阈值类型)单个
                    "value": self.triggerValueDict['one_evaluation-pass_rate'][0]['condition'],
                    "remark": "课程中心-单课程测评"
                },
                {
                    "triggerKey": "pass_number",  # 通过单课程数(循环类型)全局
                    "value": self.triggerValueDict['one_evaluation-pass_number'][0]['condition'],
                    "remark": "课程中心-单课程测评"
                },
                {
                    "triggerKey": "number",
                    "value": self.triggerValueDict['one_evaluation-number'][0]['condition'],
                    "remark": "课程中心-单课程测评"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-系列课程学习
    def test_child_learning(self):
        print(self.triggerKeyDict)
        print("\n")
        print(self.triggerValueDict)
        print("\n")
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "child_learning",
            "businessId": "12334",
            "triggerTypes": [
                {
                    "triggerKey": "complete",  # 通过(枚举类型)单个
                    "value": self.triggerValueDict['child_learning-complete'][0]['condition'],
                    "remark": "课程中心-系列课程学习"
                },
                {
                    "triggerKey": "complete_number",  # 通过题数百分比(阈值类型)单个
                    "value": self.triggerValueDict['child_learning-complete_number'][0]['condition'],
                    "remark": "课程中心-系列课程学习"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-系列课程子课程测评
    def test_series_child_evaluation(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "series_child_evaluation",
            "businessId": "22",
            "triggerTypes": [
                {
                    "triggerKey": "pass",  # 通过(枚举类型)单个
                    "value": self.triggerValueDict['series_child_evaluation-pass'][0]['condition'],
                    "remark": "课程中心-系列课程子课程测评"
                },
                {
                    "triggerKey": "pass_rate",  # 通过题数百分比(阈值类型)单个
                    "value": self.triggerValueDict['series_child_evaluation-pass_rate'][0]['condition'],
                    "remark": "课程中心-系列课程子课程测评"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-系列课程测评
    def test_child_evaluation(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "child_evaluation",
            "businessId": "22",
            "triggerTypes": [
                {
                    "triggerKey": "pass",
                    "value": 2,
                    "remark": "课程中心-系列课程测评"
                },
                {
                    "triggerKey": "pass_rate",
                    "value": 2,
                    "remark": "课程中心-系列课程测评"
                },
                {
                    "triggerKey": "pass_number",
                    "value": 2,
                    "remark": "课程中心-系列课程测评"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-学习时长
    def test_learned_time(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessId": "1",
            "businessKey": self.businessKey,
            "businessAct": "learned_time",
            "triggerTypes": [
                {
                    "triggerKey": "learned_time_total",  # 时长(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-学习时长"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-点赞课程
    def test_like(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "like",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "like_num",  # 次数(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-点赞课程"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-收藏课程
    def test_collect(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "collect_num",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "like_num",  # 次数(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-收藏课程"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-评论课程
    def test_comment(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "comment",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "comment_num",  # 次数(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-评论课程"
                },
                {
                    "triggerKey": "comment_business_num",  # 门数(循环类型)全局
                    "value": 2,
                    "remark": "课程中心-评论课程"
                }
            ]
        }
        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')
        print(result.json())

    # 课程中心-分享课程
    def test_shared(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "shared",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "shared_num",  # 次数(循环类型)全局
                    "value": 1,
                    "remark": "课程中心-分享课程"
                }
            ]
        }
        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')
        print(result.json())