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

    # 课程中心-通过测评课程数
    def test_pass_exam_business(self):
        print(self.triggerKeyDict)
        print("\n")
        print(self.triggerValueDict)
        print("\n")
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "pass_exam_business",
            "remark": "课程中心-通过测评课程数",
            "businessId": "456",
            "triggerTypes": [
                {
                    "triggerKey": "pass_exam_business_num",  # 通过测评课程数(循环类型)全局
                    "value": self.triggerValueDict['pass_exam_business-pass_exam_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')
        print(result.json())


    # 课程中心-系列课程测评
    def test_child_evaluation(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "child_evaluation",
            "remark": "课程中心-系列课程测评",
            "businessId": "22",
            "triggerTypes": [
                {
                    "triggerKey": "pass",  # 通过(枚举类型)单个
                    "value": 2
                },
                {
                    "triggerKey": "pass_rate",  # 通过题数百分比(阈值类型)单个
                    "value": 2
                },
                {
                    "triggerKey": "pass_number",  # 通过系列课程数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "child_learning",
            "remark": "课程中心-系列课程学习",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "complete",  # 完成(枚举类型)单个
                    "value": 2
                },
                {
                    "triggerKey": "complete_number",  # 完成系列课程数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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",
            "remark": "课程中心-学习时长",
            "triggerTypes": [
                {
                    "triggerKey": "learned_time_total",  # 时长(循环类型)全局
                    "value": 2
                }
            ]
        }
        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",
            "remark": "课程中心-点赞课程",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "like_num",  # 次数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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",
            "remark": "课程中心-收藏课程",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "like_num",  # 次数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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",
            "remark": "课程中心-评论课程",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "comment_num",  # 次数(循环类型)全局
                    "value": 2
                },
                {
                    "triggerKey": "comment_business_num",  # 门数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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_learning(self):
        data = {
            "memUid": self.jipeihong_uid,
            "businessKey": self.businessKey,
            "businessAct": "one_learning",
            "remark": "课程中心-单课程学习",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "complete",  # 完成(枚举类型)单个
                    "value": 2
                },
                {
                    "triggerKey": "number",  # 完成单课程数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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",
            "remark": "课程中心-分享课程",
            "businessId": "1",
            "triggerTypes": [
                {
                    "triggerKey": "shared_num",  # 次数(循环类型)全局
                    "value": 2
                }
            ]
        }
        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())