Exemplo n.º 1
0
    def getCourseList(self):
        url = "%sgetCourseList" % config.API_ADDRESS;
        get_course_list = InGetCourseList(config.API_KEY, config.CATEGORY_ID, 'GS011', SORT);
        data = ConvertObj.convert_to_dict(get_course_list);
        interface_result = HttpRequest.requestInterface(url, data);
        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回code错误"
        object = interface_result.error_reason;
        for course in object['data']:
            print(course['name']);
            print(course['id']);

            assert course['id'] is not None, "id 不能为空";
            assert course['name'] is not None, "课程名称不能为空";
            assert course['name_us'] is not None, "课程英文名称 不能为空";
            assert course['organ_id'] is not None, "组织机构ID 不能为空";
            assert course['organ_name'] is not None, "组织机构名称 不能为空";
            assert course['subject_id'] is not None, "科目ID 不能为空";
            assert course['subject_name'] is not None, "科目名称 不能为空";
            assert course['watch_count'] is not None, "观看数量 不能为空";
            assert course['favor_count'] is not None, "收藏数量 不能为空";
            assert course['img_url'] is not None, "图片地址 不能为空";
            from util.UtilMethod import get_url_isexist
            img_url_http_code = get_url_isexist(course['img_url'])
            assert img_url_http_code == config.URL_SUCCESS_CODE, "图片地址不存在";

            assert course['type'] is not None, "课程类型类型不能为空(课程类型1-普通课程,2-专题课程";
        return object;
Exemplo n.º 2
0
    def getCourseInfo(self):
        url = "%sgetCourseInfo" % config.API_ADDRESS;
        favorTheme = InGetCourseInfo(config.API_KEY, config.USER_ID, 'HSNVC1281');

        data = ConvertObj.convert_to_dict(favorTheme);
        interface_result = HttpRequest.requestInterface(url, data);
        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
        object = interface_result.error_reason;

        for object_info in object['data']:
            assert object_info['id'] is not None, "ID不能为空";
            print(object_info['name']);
            assert object_info['share_url'] is not None, "分享的Url不能为空";
            from util.UtilMethod import get_url_isexist
            share_url_http_code = get_url_isexist(object_info['share_url'])
            assert share_url_http_code == config.URL_SUCCESS_CODE, "分享的地址不存在";

            assert object_info['subject_name'] is not None, "科目名称不能为空";
            assert object_info['subject_id'] is not None, "科目ID不能为空";
            assert object_info['category_id'] is not None, "分类ID不能为空";
            assert object_info['category_name'] is not None, "分类名称不能为空";
            assert object_info['praise_count'] is not None, "praise_count不能为空";
            assert object_info['watch_count'] is not None, "watch_count不能为空";
            assert object_info['organ_name'] is not None, "organ_name不能为空";
            assert object_info['img_url'] is not None, "img_url不能为空";
            assert object_info['organ_id'] is not None, "organ_id不能为空";
            assert object_info['name'] is not None, "name不能为空";
            assert object_info['name_us'] is not None, "name_us不能为空";
            assert object_info['summary'] is not None, "summary不能为空";

            assert object_info['img_url'] is not None, "img_url不能为空";
            img_url_http_code = get_url_isexist(object_info['img_url'])
            assert img_url_http_code == config.URL_SUCCESS_CODE, "课程图片地址不存在";
Exemplo n.º 3
0
    def getCoursewareInfo(self):
        url = "%sgetCoursewareInfo" % config.API_ADDRESS
        favorTheme = InGetCoursewareInfo(config.API_KEY, config.USER_ID,
                                         "HSNVC326", 'HSNCV7489', 8, 0, 1, 1,
                                         1)
        data = ConvertObj.convert_to_dict(favorTheme)
        try:
            interface_result = HttpRequest.requestInterface(url, data)
            assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
            object = interface_result.error_reason

            for object_info in object['data']:
                assert object_info['fhd_url'] is not None, "fhd_url地址不能为空"
                assert object_info['hd_url'] is not None, "hd_url地址不能为空"
                assert object_info['sd_url'] is not None, "sd_url地址不能为空"
                assert object_info['ld_url'] is not None, "ld_url地址不能为空"
                assert object_info['id'] is not None, "id地址不能为空"

                img_url_http_code = get_url_isexist(object_info['fhd_url'])
                assert img_url_http_code == config.URL_SUCCESS_CODE, "fhd_url地址不存在"

                img_url_http_code = get_url_isexist(object_info['hd_url'])
                assert img_url_http_code == config.URL_SUCCESS_CODE, "hd_url地址不存在"

                img_url_http_code = get_url_isexist(object_info['sd_url'])
                assert img_url_http_code == config.URL_SUCCESS_CODE, "sd_url地址不存在"

                img_url_http_code = get_url_isexist(object_info['ld_url'])
                assert img_url_http_code == config.URL_SUCCESS_CODE, "ld_url地址不存在"

        except Exception as e:
            print(Exception, "----Exception-------------------:", e)
Exemplo n.º 4
0
def favorTheme():
    url = "%sfavorTheme" % config.API_ADDRESS
    print(url)
    relativeTheme = InFavorTheme(config.API_KEY, config.USER_ID, 'TH107')
    data = ConvertObj.convert_to_dict(relativeTheme)
    interface_result = HttpRequest.requestInterface(url, data)
    assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
    object = interface_result.error_reason
    assert object['code'] == config.INTERFACE_SUCCESS_CODE, "收藏专题失败"
Exemplo n.º 5
0
 def afterWatchCourse(self):
     url = "%safterWatchCourse" % config.API_ADDRESS
     favorTheme = InAfterWatchCourse(config.API_KEY, 10599667, 'HSNVC326',
                                     'HSNCV7489', 8, 0, 1, 1,
                                     'DBA30104150100260')
     data = ConvertObj.convert_to_dict(favorTheme)
     interface_result = HttpRequest.requestInterface(url, data)
     assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
     object = interface_result.error_reason
     assert object['code'] is not None, "上报观看行为失败"
Exemplo n.º 6
0
 def test_praiseCourse(self):
     url = "%spraiseCourse" % config.API_ADDRESS
     favorTheme = InPraiseCourse(config.IDS, config.USER_ID,
                                 config.REGISTER_ID, config.API_KEY)
     data = ConvertObj.convert_to_dict(favorTheme)
     interface_result = HttpRequest.requestInterface(url, data)
     assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
     object = interface_result.error_reason
     for object_info in object['data']:
         assert object_info['count'] is not None, "点赞数量没有增加"
Exemplo n.º 7
0
    def getCourseCount(self):
        url = "%sgetCourseCount" % config.API_ADDRESS;

        favorTheme = InGetCourseCount(config.API_KEY, config.USER_ID, 1);

        data = ConvertObj.convert_to_dict(favorTheme);

        get_Favor_Theme_List = HttpRequest.requestInterface(url, data);

        assert get_Favor_Theme_List['code'] == config.INTERFACE_SUCCESS_CODE, "接口返回码错误";
        print(get_Favor_Theme_List['msg']);
Exemplo n.º 8
0
    def getThemeCourseList(self):
        url = "%sgetThemeCourseList" % config.API_ADDRESS;

        favorTheme = InGetThemeCourseList(config.API_KEY, 'TH113');

        data = ConvertObj.convert_to_dict(favorTheme);

        interface_result = HttpRequest.requestInterface(url, data);

        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
        object = interface_result.error_reason;
        assert object['code'] == config.INTERFACE_SUCCESS_CODE, "获取专题的课程列表失败";
Exemplo n.º 9
0
        def getFilterConditionList(self):
            url = "%sgetFilterConditionList" % config.API_ADDRESS;

            favorTheme = InGetFilterConditionList(config.API_KEY, 'HSNVC326', config.USER_ID, 1);

            data = ConvertObj.convert_to_dict(favorTheme);

            get_Favor_Theme_List = HttpRequest.requestInterface(url, data);

            print(get_Favor_Theme_List);
            print(get_Favor_Theme_List['code']);
            print(get_Favor_Theme_List['msg']);
Exemplo n.º 10
0
def getHomeRecommend():
    url = "%sgetHomeRecommend" % config.API_ADDRESS
    favorTheme = InGetHomeRecommend(config.API_KEY, PROJECT_TYPE,
                                    config.USER_ID)
    # 将对象转成字典
    data = ConvertObj.convert_to_dict(favorTheme)
    interface_result = HttpRequest.requestInterface(url, data)

    assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
    object = interface_result.error_reason
    assert object['code'] == config.INTERFACE_SUCCESS_CODE, "获取相关专题失败"
    for favorTheme in object['data']:
        check_banner_url_is_exist(favorTheme)  # 判断banner地址是否存在
Exemplo n.º 11
0
    def clearWatchHistory(self):
        url = "%sclearWatchHistory" % config.API_ADDRESS
        favorTheme = InClearWatchHistory(config.API_KEY, 10599667)
        data = ConvertObj.convert_to_dict(favorTheme)
        interface_result = HttpRequest.requestInterface(url, data)
        try:
            assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
            object = interface_result.error_reason
            assert object[
                "code"] == config.INTERFACE_SUCCESS_CODE, "清空观看历史,清除失败"

        except Exception as e:
            print(Exception, "---------------Exception----------:", e)
Exemplo n.º 12
0
def getThemeList():
    url = "%sgetThemeList" % config.API_ADDRESS
    themeInfo = InGetThemeList(config.API_KEY, 0, 20)
    data = ConvertObj.convert_to_dict(themeInfo)
    interface_result = HttpRequest.requestInterface(url, data)
    assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
    object = interface_result.error_reason
    for theme in object['data']:
        assert theme['id'] is not None, "id 不能为空"
        assert theme['img_url'] is not None, "img_url 不能为空"
        assert theme['name'] is not None, "专题名称 不能为空"
        img_url_http_code = get_url_isexist(theme['img_url'])
        assert img_url_http_code == config.URL_SUCCESS_CODE, "缩略图片地址不存在"
Exemplo n.º 13
0
def getFavorThemeList():
    url = "%sgetFavorThemeList" % config.API_ADDRESS
    favorTheme = InGetFavorThemeList(config.API_KEY, config.USER_ID, 0, 36,
                                     'DMA31105150914191')
    data = ConvertObj.convert_to_dict(favorTheme)
    interface_result = HttpRequest.requestInterface(url, data)
    assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
    object = interface_result.error_reason
    for object_info in object['data']:
        assert object_info['id'] is not None, "id不能为空"
        assert object_info['img_url'] is not None, "图片Url不能为空"
        assert object_info['name'] is not None, "专题图片不能为空"
        url = object_info['img_url']
        img_url_http_code = get_url_isexist(url)
        assert img_url_http_code == config.URL_SUCCESS_CODE, "图片地址不存在"
Exemplo n.º 14
0
 def getLearnedCourseList(self):
     url = "%sgetLearnedCourseList" % config.API_ADDRESS;
     favorTheme = InGetLearnedCourseList(config.API_KEY, 'TH113', 10265093, 0, 0, 10000);
     data = ConvertObj.convert_to_dict(favorTheme);
     interface_result = HttpRequest.requestInterface(url, data);
     assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误";
     object = interface_result.error_reason;
     for object_info in object['data']:
         assert object_info['id'] is not None, "id不能为空";
         assert object_info['name'] is not None, "name 不能为空";
         assert object_info['name_us'] is not None, "name_us 不能为空";
         assert object_info['img_url'] is not None, "img_url 不能为空";
         assert object_info['courseware_total_count'] is not None, "课件总数量不正常";
         assert object_info['courseware_finished_count'] is not None, "courseware_finished_count 不能为空";
         assert object_info['courseware_total_count'] is not None, "课件总数量不正常";
         assert object_info['type'] is not None, "type不能为空";
Exemplo n.º 15
0
def getThemeInfo():
    url = "%sgetThemeInfo" % config.API_ADDRESS
    themeInfo = InGetThemeInfo(config.API_KEY, config.USER_ID, 'TH314')
    data = ConvertObj.convert_to_dict(themeInfo)
    interface_result = HttpRequest.requestInterface(url, data)
    assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
    object = interface_result.error_reason
    for object_info in object['data']:
        assert object_info['name'] is not None, "专题名称不能为空"
        assert object_info['background_img_url'] is not None, "背景图片不能为空"
        assert object_info['img_url'] is not None, "缩略图片不能为空"
        background_http_code = get_url_isexist(
            object_info['background_img_url'])
        assert background_http_code == config.URL_SUCCESS_CODE, "背景图片地址不存在"
        background_http_code = get_url_isexist(object_info['img_url'])
        assert background_http_code == config.URL_SUCCESS_CODE, "缩略图片地址不存在"
Exemplo n.º 16
0
    def getCoursewareList(self):
        url = "%sgetCoursewareList" % config.API_ADDRESS
        course_list = InGetCoursewareList(config.API_KEY, 'HSNVC1272',
                                          10599667, 0, 0, 10000)
        data = ConvertObj.convert_to_dict(course_list)
        interface_result = HttpRequest.requestInterface(url, data)
        try:
            assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
            object = interface_result.error_reason
            for data_info in object['data']:
                print(data_info['name'])
                assert data_info['name'] is not None, "课件名称不能为空"
                # assert data_info['name_us'] is not None, "课件英文名称不能为空";
                assert data_info['id'] is not None, "课件ID不能为空"

        except Exception as e:
            print(Exception, ":------getCoursewareList---------------", e)
Exemplo n.º 17
0
    def test_favorCourse(self):
        url = "%sfavorCourse" % config.API_ADDRESS
        favorTheme = InFavorCourse(config.IDS, config.USER_ID, config.API_KEY)
        data = ConvertObj.convert_to_dict(favorTheme)
        interface_result = HttpRequest.requestInterface(url, data)

        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
        object = interface_result.error_reason
        assert object['code'] == config.INTERFACE_SUCCESS_CODE, "接口返回码错误"
        for object_info in object['data']:
            assert object_info['count'] is not None, "攒点数量有误"
        # 查看收藏的课程
        object = CourseRelative.getFavorCourseList(self)
        for favorTheme in object['data']:
            # print(favorTheme['id']);
            if config.IDS == favorTheme['id']:
                print("------true-------------")
Exemplo n.º 18
0
    def test_remove_user_collection(self):
        url = "%sremoveUserFavorCourse/%s/%s/%s" % (
            config.API_ADDRESS, config.CATEGORY_TYPE, config.TYPE, config.IDS)
        inputParam = InRemoveUserFavorCourse(config.API_KEY, config.USER_ID)
        data = ConvertObj.convert_to_dict(inputParam)
        interface_result = HttpRequest.requestInterface(url, data)
        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回码错误"
        object = interface_result.error_reason
        code = object['code']
        print(code)
        assert code == config.INTERFACE_SUCCESS_CODE, "清除用户历史记录失败"
        print("----------------------------------")
        object = CourseRelative.getFavorCourseList(self)

        for favorTheme in object['data']:
            # print(favorTheme['id']);
            if config.IDS == favorTheme['id']:
                print("------false-------------")
Exemplo n.º 19
0
    def getWatchHistory(self):
        url = "%sgetWatchHistory" % config.API_ADDRESS
        favorTheme = InGetWatchHistory(config.API_KEY, 10599667)
        # 将对象转成字典
        data = ConvertObj.convert_to_dict(favorTheme)

        interface_result = HttpRequest.requestInterface(url, data)
        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口请求失败"
        object = interface_result.error_reason
        for favorTheme in object['data']:
            assert favorTheme['id'] is not None, "id不能为空"
            assert favorTheme['courseware_id'] is not None, "课件id不能为空"
            assert favorTheme['name'] is not None, "课程名称不能为空"
            assert favorTheme['name_us'] is not None, "课程英文名称不能为空"
            assert favorTheme['img_url'] is not None, "图片地址不能为空"
            assert favorTheme['courseware_name'] is not None, "课件名称不能为空"
            assert favorTheme['type'] is not None, "类型不能为空"
            assert favorTheme['view_type'] is not None, "view_type不能为空"
            assert favorTheme['status'] is not None, "状态不能为空"
Exemplo n.º 20
0
    def getCategorySubjects(self,category_id):
        url = "%sgetCategorySubjects" % config.API_ADDRESS;

        favorTheme = InGetCategorySubjects(config.API_KEY, config.USER_ID, category_id);
        from util import ConvertObj
        data = ConvertObj.convert_to_dict(favorTheme);
        from util import HttpRequest
        interface_result = HttpRequest.requestInterface(url, data);
        try:
            assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口请求失败";
            object = interface_result.error_reason;
            assert object['code'] == config.INTERFACE_SUCCESS_CODE, "接口返回码不正确";
            for favorTheme in object['data']:
                assert favorTheme["id"] is not None, "id 不能为空";
                assert favorTheme["name"] is not None, "科目名称不能为空";
                print(favorTheme['id']);
                print(favorTheme['name']);
            return object;
        except Exception as e:
            print(Exception, e);
Exemplo n.º 21
0
    def getCourseCategories(self):
        url = "%sgetCourseCategories" % config.API_ADDRESS;
        object_vo = InGetCourseCategories(config.API_KEY);
        data = ConvertObj.convert_to_dict(object_vo);
        interface_result = HttpRequest.requestInterface(url, data);
        try:
            if interface_result.result_status == config.INTERFACE_SUCCESS_STATUS:
                object = interface_result.error_reason;

                for obj_detail in object['data']:
                    img_url = obj_detail['img_url'];
                    assert obj_detail['id'] is not None, "id不能为空";
                    assert obj_detail['name'] is not None, "name不能为空";
                    assert obj_detail['sort'] is not None, "排序不能为空";
                    assert obj_detail['img_url'] is not None, "分类图片不能为空";
                    img_url_http_code = get_url_isexist(img_url)
                    assert img_url_http_code == config.URL_SUCCESS_CODE, "分类图片地址不存在";


        except Exception as e:
            print(Exception, e);
Exemplo n.º 22
0
    def getFavorCourseList(self):
        url = "%sgetFavorCourseList" % config.API_ADDRESS;

        favorTheme = InGetFavorCourseList(config.USER_ID, config.API_KEY, 0, 10);

        from util import ConvertObj
        data = ConvertObj.convert_to_dict(favorTheme);

        # get_Favor_Theme_List = HttpRequest.requestInterface(url, data);
        from util import HttpRequest
        interface_result = HttpRequest.requestInterface(url, data);
        assert interface_result.result_status == config.INTERFACE_SUCCESS_STATUS, "接口返回code错误"
        object = interface_result.error_reason;

        for favorTheme in object['data']:
            print(favorTheme['id']);
            print(favorTheme['name']);

            assert favorTheme['id'] is not None, "ID不能为空";
            assert favorTheme['subject_name'] is not None, "科目名称不能为空";
            assert favorTheme['subject_id'] is not None, "科目ID不能为空";
            assert favorTheme['category_id'] is not None, "分类ID不能为空";
            assert favorTheme['category_name'] is not None, "分类名称不能为空";
            assert favorTheme['organ_name'] is not None, "组织机构的ID不能为空";
            assert favorTheme['img_url'] is not None, "组织机构的ID不能为空";
            assert favorTheme['name'] is not None, "课程名称不能为空";
            assert favorTheme['summary'] is not None, "备注不能为空";

        return object;
            # print(favorTheme['condition_id']);
            # print(favorTheme['condition_name']);
            # print(favorTheme['label_id']);
            # print(favorTheme['label_name']);
            # print(favorTheme['praise_count']);
            # print(favorTheme['is_favor']);
            # print(favorTheme['is_praised']);
            # print(favorTheme['watch_count']);
            # print(favorTheme['speaker_id']);
            # print(favorTheme['speaker_name']);
            # print(favorTheme['img_url_us']);
            # print(favorTheme['type']);
            # print(favorTheme['uniq_id']);
            # print(favorTheme['organ_id']);
            # print(favorTheme['name']);
            # print(favorTheme['name_us']);
            # print(favorTheme['summary']);
            # print(favorTheme['status']);
            # print(favorTheme['update_status']);


            # 获取课程分类列表

        def getFilterConditionList(self):
            url = "%sgetFilterConditionList" % config.API_ADDRESS;

            favorTheme = InGetFilterConditionList(config.API_KEY, 'HSNVC326', config.USER_ID, 1);

            data = ConvertObj.convert_to_dict(favorTheme);

            get_Favor_Theme_List = HttpRequest.requestInterface(url, data);

            print(get_Favor_Theme_List);
            print(get_Favor_Theme_List['code']);
            print(get_Favor_Theme_List['msg']);