def test_subject(self):
        """
        学习专题数据回传接口
        """
        # mock 参数
        data = {
            'apikey': ConsumerLearningProgress.API_KEY,
            'timestamp': int(currentTimeMillis() * 1000),
            'name': user_info['accountName'],
            'organizationCode': user_info['organizationCode'],
            'courseId': 'c5526fe0-edc6-4bd6-8c25-1e840b82ab80',
            'finishStatus': 1,
            'finishTime': '',
            'beginTime': int(currentTimeMillis() * 1000),
            'finishNum': 0,
            'studyTotalTime': 1111111
        }

        if isDebug:
            # 联调参数
            debugParams = 'finishStatus=1&finishTime=&apikey=e61121d3d39f649c1f847e470abf2e95&name=admin&organizationCode=cmcc&sign=A87096F9C698CB141F2AC81B7FD3B3D0&beginTime=1580631436742&courseId=acc681d3-3c74-44bc-80f4-86dfefb10dbf&finishNum=0&studyTotalTime=1111111&timestamp=1580649261100'

            # 处理原始参数
            data = originParam(debugParams)

        url = 'http://localhost:8086/api/v1/course-study/resource/learning/progress/subject'
        self.result = r.post(url=url,
                             data=buildParams(
                                 data, ConsumerLearningProgress.SECRET_KEY))
Exemplo n.º 2
0
    def test_subject(self):
        """
        学习专题数据回传接口
        """
        # mock 参数
        data = {
            'apikey': LearningProgress.API_KEY,
            'timestamp': int(currentTimeMillis() * 1000),
            'accountName': user_info['accountName'],
            'organizationCode': user_info['organizationCode'],
            'courseId': 'c5526fe0-edc6-4bd6-8c25-1e840b82ab80',
            'finishStatus': 1,
            'finishTime': int(currentTimeMillis() * 1000),
            'beginTime': int(currentTimeMillis() * 1000),
            'finishNum': 0,
            'studyTotalTime': 1111111
        }

        if isDebug:
            # 联调参数
            debugParams = 'finishStatus=1&finishTime=0&apikey=a5c11b18ede548148f24&accountName=admin&organizationCode=zz_BAde1af01&sign=F9B8DF305E3A9E6BF90FC559070F3583&beginTime=1573609703984&courseId=27fcd65a-1dc8-421b-bf06-627ad86a6cdd&studyTotalTime=5&timestamp=1573609703984&'

            # 处理原始参数
            data = originParam(debugParams)

        url = LearningProgress.subject + '?' + buildParams(data)
        self.result = r.get(url)
    def test_course(self):
        """
        课程数据回传接口
        """
        # mock 参数
        data = {
            'apikey': ConsumerLearningProgress.API_KEY,
            'timestamp': int(currentTimeMillis() * 1000),
            'name': user_info['accountName'],
            'organizationCode': user_info['organizationCode'],
            "courseId": "db15a39f-5c82-433a-ba83-a42123422f85",
            "finishStatus": "0",
            "studyTotalTime": "0",
        }

        if isDebug:
            # 联调参数
            debugParams = 'finishStatus=0&apikey=e61121d3d39f649c1f847e470abf2e95&name=admin&organizationCode=cmcc&sign=B80DE72362206CFE54C73F9BA9A05155&courseId=db15a39f-5c82-433a-ba83-a42123422f85&studyTotalTime=0&timestamp=1580649104872'
            # 处理原始参数
            data = originParam(debugParams)

        print(r.toJsonString(data))

        url = 'http://localhost:8086/api/v1/course-study/resource/learning/progress/course'
        self.result = r.post(url=url,
                             data=buildParams(
                                 data, ConsumerLearningProgress.SECRET_KEY))
Exemplo n.º 4
0
 def test_userInfo(self):
     """
     获取用户信息
     """
     # mock 参数
     data = {
         'apikey': LearningProgress.API_KEY,
         'timestamp': int(currentTimeMillis() * 1000),
         'token': 'ea992d3ec553203e25032b5a5dd72510'
     }
     url = 'https://zxhcs.zhixueyun.com/api/v1/content/user/info/simple?' + \
         buildParams(data, LearningProgress.SECRET_KEY)
     # url = UserInfo.url+'?'+buildParams(data,LearningProgress.SECRET_KEY)
     #     API_KEY = '8bf8e66924e3f63453842084995354d6'
     # SECRET_KEY = 'd7247877a06de4b0ed2d9825d6ed134a'
     self.result = r.get(url)
Exemplo n.º 5
0
def getToken(url=URL_AUTH, data=None, content=None):
    if content == '' or content == None:
        token_file = open(token_json_path, 'r')
        content = token_file.read()
        token_file.close()

    if content == '' or content == None:
        content = login(url, data)
        return getToken(url, content)

    jsonObj = json.loads(content)
    access_token = jsonObj['access_token']
    token_type = jsonObj['token_type']
    out_of_time = jsonObj['out_of_time']

    if out_of_time < currentTimeMillis() + 5:
        content = login(url, data)
        return getToken(url, content)

    token = token_type + '__' + access_token
    return token
Exemplo n.º 6
0
def login(url=URL_AUTH, data=None):
    if data is None:
        return None

    r = HttpUtils()
    result = r.post(url, data=data)
    if result.status_code != 200:
        print('获取token失败')
        os._exit(0)
    token_file = open(token_json_path, 'w')
    jsonObj = json.loads(result.text)
    expires_in = jsonObj['expires_in']
    # 过期时间
    out_of_time = currentTimeMillis() + expires_in
    jsonObj['out_of_time'] = out_of_time
    jsonObj['expires_time'] = DateTime(out_of_time)
    jsonObj['create_time'] = DateTime()
    jsonStr = json.dumps(jsonObj)
    token_file.write(jsonStr)
    token_file.close()
    r.logJson(jsonStr)
    return jsonStr
Exemplo n.º 7
0
    def test_activity(self):
        """
        外部活动数据回传接口
        """
        # mock 参数
        data = {
            'apikey': LearningProgress.API_KEY,
            'timestamp': int(currentTimeMillis() * 1000),
            'accountName': user_info['accountName'],
            'organizationCode': user_info['organizationCode'],
            'externalActivityId': 'd595bda0-0e83-42ce-837e-4e0629f69b95',
            'studyStatus': 2
        }

        if isDebug:
            # 联调参数
            debugParams = 'electiveUnit=1&apikey=a5c11b18ede548148f24&obligatoryFinished=1&accountName=admin&obligatoryTotal=3&sign=D2DEF11F4B127E69270E63FA92D24E57&obligatoryUnit=1&seconds=10&organizationCode=zz_BAde1af01&externalActivityId=cee5bbff-05de-11ea-843a-00163e11d483&electiveTotal=1&electiveFinished=0&timestamp=1573627257470&studyStatus=1&'
            # 处理原始参数
            data = originParam(debugParams)

        url = LearningProgress.external_activity + '?' + buildParams(data)
        self.result = r.get(url)
    def test_activity(self):
        """
        外部活动数据回传接口
        """
        # mock 参数
        data = {
            'apikey': ConsumerLearningProgress.API_KEY,
            'timestamp': int(currentTimeMillis() * 1000),
            'name': user_info['accountName'],
            'organizationCode': user_info['organizationCode'],
            'externalActivityId': 'd595bda0-0e83-42ce-837e-4e0629f69b95',
            'studyStatus': 2
        }

        if isDebug:
            # 联调参数
            debugParams = 'apikey=e61121d3d39f649c1f847e470abf2e95&name=admin&organizationCode=cmcc&externalActivityId=541f4c59-690a-4aec-8eb3-253f175c70ba&sign=1DA098D37909C254266A6977F6FB5E6C&timestamp=1580651804318&studyStatus=1'
            # 处理原始参数
            data = originParam(debugParams)

        url = 'http://localhost:8086/api/v1/course-study/resource/learning/progress/externalActivity'
        self.result = r.post(url=url,
                             data=buildParams(
                                 data, ConsumerLearningProgress.SECRET_KEY))