コード例 #1
0
 def test_add_case_to_classify(self, api_object):
     """新增案件到指定案件分类下"""
     # 新增案件分类
     level_1_classify_name = create_random_str(8)
     res_1 = api_object.add_level_1_case_classify(level_1_classify_name)
     level_1_classify_id = res_1.get('data').get('typeId')
     # 新增二级案件分类
     level_2_classify_name = create_random_str(8)
     classify_list = [{
         "parentId": level_1_classify_id,
         "sign": f"name0-{level_2_classify_name}",
         "name": level_2_classify_name
     }]
     api_object.add_level_2_case_classify(classify_list)
     level_2_classify_id = api_object.get_case_classify_id(
         level_1_classify_id, level_2_classify_name)
     # 新增案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name,
                                   case_classify_id=level_2_classify_id)
     # 断言案件是否在案件分类下
     classify_id = api_object.get_case_belong_classify_id(case_id)
     assert level_2_classify_id == classify_id
     # 直接删除一级案件分类进行环境还原
     api_object.remove_case_classify(level_1_classify_id)
コード例 #2
0
 def test_edit_case_classify(self, api_object):
     """测试编辑案件分类"""
     # 新建一级案件分类
     classify_name = create_random_str(8)
     res = api_object.add_level_1_case_classify(classify_name)
     classify_id = res.get('data').get('typeId')
     # 修改案件分类名称
     new_classify_name = create_random_str(8)
     api_object.edit_case_classify(classify_id, new_classify_name)
     # 断言是否修改成功
     find_result = api_object.find_case_classify_name_by_id(
         classify_id, new_classify_name)
     assert find_result
     # 环境清理
     api_object.remove_case_classify(classify_id)
コード例 #3
0
 def test_add_tag(self, api_object):
     """测试添加标记"""
     # 从excel读取数据
     excel_data = read_excel('test_add_tag')
     file_path = excel_data.get('file_path')
     begin_time = int(excel_data.get('begin_time'))
     end_time = int(excel_data.get('end_time'))
     tag_name = excel_data.get('tag_name')
     comment = excel_data.get('comment')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传音频
     file_id = api_object.upload_file_to_folder(case_id,
                                                file_path,
                                                folder_id=folder_id)
     # 给音频文件添加标记
     tag_id = api_object.add_tag(begin_time, end_time, case_id, tag_name,
                                 file_id, comment)
     # 验证标记是否添加成功
     tag_info = api_object.get_tag_info(case_id, file_id, tag_id)
     res_tag_name = tag_info.get('voiceTagName')
     res_tag_comment = tag_info.get('comment')
     res_begin_time = tag_info.get('beginTime')
     res_end_time = tag_info.get('endTime')
     assert (res_tag_name == tag_name and res_tag_comment == comment
             and res_begin_time == begin_time and res_end_time == end_time)
コード例 #4
0
 def test_case_allocate_user(self, api_object):
     """分发案件个单个用户"""
     # 从excel读取数据
     excel_data = read_excel('test_case_allocate_user')
     file_path = excel_data.get('file_path')
     target_user_group = excel_data.get('target_user_group')
     target_username = excel_data.get('target_username')
     target_password = excel_data.get('target_password')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传音频
     api_object.upload_file_to_folder(case_id,
                                      file_path,
                                      folder_id=folder_id)
     # 获取用户id
     user_group_id = api_object.get_auth_group_id_by_name(target_user_group)
     user_id = api_object.get_user_id_by_name(user_group_id,
                                              target_username)
     # 将案件转发给他人
     user_ids = list()
     user_ids.append(user_id)
     api_object.case_allocate(case_id, user_ids)
     # 验证用户是否接收到案件
     new_operate_api = OperateApi(target_username, target_password)
     new_operate_api.get_session_id()
     target_case_name = case_name + '_' + target_username
     find_result = new_operate_api.find_case_in_case_list(target_case_name)
     assert find_result
コード例 #5
0
 def test_remove_case_classify(self, api_object):
     """测试删除案件分类"""
     # 新建一级案件分类
     classify_name = create_random_str(8)
     res = api_object.add_level_1_case_classify(classify_name)
     classify_id = res.get('data').get('typeId')
     # 删除案件分类
     api_object.remove_case_classify(classify_id)
     # 验证能否找到被删除的案件分类
     find_result = api_object.find_case_classify_by_id(classify_id)
     assert find_result is False
コード例 #6
0
 def test_add_folder(self, api_object):
     """测试新增文件夹"""
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 验证案件下是否存在新增的文件夹
     find_result = api_object.find_folder_by_id(case_id, folder_id)
     assert find_result
コード例 #7
0
 def test_add_level_2_case_classify(self, api_object):
     """测试新增二级案件分类"""
     # 先新增一级案件分类
     level_1_classify_name = create_random_str(8)
     res_1 = api_object.add_level_1_case_classify(level_1_classify_name)
     level_1_classify_id = res_1.get('data').get('typeId')
     # 新增二级案件分类
     level_2_classify_name = create_random_str(8)
     classify_list = [{
         "parentId": level_1_classify_id,
         "sign": f"name0-{level_2_classify_name}",
         "name": level_2_classify_name
     }]
     res_2 = api_object.add_level_2_case_classify(classify_list)
     has_error = res_2.get('hasError')
     if has_error is False:
         find_result = api_object.find_level_2_case_classify(
             level_2_classify_name, level_1_classify_id)
         assert find_result
     # 直接删除一级案件分类进行环境还原
     api_object.remove_case_classify(level_1_classify_id)
コード例 #8
0
 def test_add_level_1_case_classify(self, api_object):
     """测试新建一级案件分类"""
     classify_name = create_random_str(8)
     res = api_object.add_level_1_case_classify(classify_name)
     has_error = res.get('hasError')
     if has_error is False:
         classify_id = res.get('data').get('typeId')
         find_result = api_object.find_case_classify_by_id(classify_id)
         assert find_result
         # 环境还原
         api_object.remove_case_classify(classify_id)
     else:
         assert False
コード例 #9
0
 def test_upload_picture(self, api_object):
     """上传图片"""
     # 从excel读取数据
     excel_data = read_excel('test_upload_picture')
     file_path = excel_data.get('file_path')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传图片
     mime_type = 'application/octet-stream'
     file_id = api_object.upload_file_to_folder(case_id, file_path,
                                                mime_type, folder_id)
     # 验证文件是否上传成功
     find_result = api_object.find_file_by_id(case_id, folder_id, file_id)
     assert find_result
コード例 #10
0
 def test_upload_voice(self, api_object):
     """上传音频"""
     # 从excel读取数据
     excel_data = read_excel('test_upload_voice')
     file_path = excel_data.get('file_path')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传音频
     file_id = api_object.upload_file_to_folder(case_id,
                                                file_path,
                                                folder_id=folder_id)
     # 验证文件是否上传成功
     find_result = api_object.find_file_by_id(case_id, folder_id, file_id)
     assert find_result
コード例 #11
0
 def test_recover_tag(self, api_object):
     """回收站还原标记"""
     # 从excel读取数据
     excel_data = read_excel('test_recover_tag')
     file_path = excel_data.get('file_path')
     begin_time_1 = int(excel_data.get('begin_time_1'))
     end_time_1 = int(excel_data.get('end_time_1'))
     tag_name_1 = excel_data.get('tag_name_1')
     comment_1 = excel_data.get('comment_1')
     begin_time_2 = int(excel_data.get('begin_time_2'))
     end_time_2 = int(excel_data.get('end_time_2'))
     tag_name_2 = excel_data.get('tag_name_2')
     comment_2 = excel_data.get('comment_2')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传音频
     file_id = api_object.upload_file_to_folder(case_id,
                                                file_path,
                                                folder_id=folder_id)
     # 给音频文件添加标记
     tag_id_1 = api_object.add_tag(begin_time_1, end_time_1, case_id,
                                   tag_name_1, file_id, comment_1)
     tag_id_2 = api_object.add_tag(begin_time_2, end_time_2, case_id,
                                   tag_name_2, file_id, comment_2)
     tag_ids = [tag_id_1, tag_id_2]
     # 删除标记
     api_object.remove_tag(tag_ids)
     # 还原标记
     api_object.recover_tag(tag_ids)
     # 验证标记已经还原到标记列表
     find_result_1 = api_object.find_tag_by_id(case_id, file_id, tag_id_1)
     assert find_result_1
     find_result_2 = api_object.find_tag_by_id(case_id, file_id, tag_id_2)
     assert find_result_2
     # 验证回收站不存在被还原的标记
     find_result_3 = api_object.find_tag_in_recycle_by_id(case_id, tag_id_1)
     assert find_result_3 is False
     find_result_4 = api_object.find_tag_in_recycle_by_id(case_id, tag_id_2)
     assert find_result_4 is False
コード例 #12
0
 def test_rename_file(self, api_object):
     """测试文件重命名"""
     # 从excel读取数据
     excel_data = read_excel('test_upload_picture')
     file_path = excel_data.get('file_path')
     file_name = get_file_name(file_path)
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传图片
     mime_type = 'application/octet-stream'
     file_id = api_object.upload_file_to_folder(case_id, file_path,
                                                mime_type, folder_id)
     # 修改文件名称
     new_name = 'new_' + file_name
     api_object.rename_file(file_id, new_name)
     find_result = api_object.find_file_by_name(case_id, folder_id,
                                                new_name)
     assert find_result
コード例 #13
0
 def test_del_hearing_analysis(self, api_object):
     """测试删除听觉量化分析记录"""
     # 从excel读取数据
     excel_data = read_excel('test_del_hearing_analysis')
     file_path_1 = excel_data.get('file_path_1')
     file_path_2 = excel_data.get('file_path_2')
     recode_state = bool(excel_data.get('recode_state'))
     pitch_level_score = int(excel_data.get('pitch_level_score'))
     pitch_level_comment = excel_data.get('pitch_level_comment')
     pitch_variation_range_score = int(
         excel_data.get('pitch_variation_range_score'))
     pitch_variation_range_comment = excel_data.get(
         'pitch_variation_range_comment')
     pitch_model_score = int(excel_data.get('pitch_model_score'))
     pitch_model_comment = excel_data.get('pitch_model_comment')
     throat_allover_score = int(excel_data.get('throat_allover_score'))
     throat_allover_comment = excel_data.get('throat_allover_comment')
     throat_bubble_score = int(excel_data.get('throat_bubble_score'))
     throat_bubble_comment = excel_data.get('throat_bubble_comment')
     throat_other_score = int(excel_data.get('throat_other_score'))
     throat_other_comment = excel_data.get('throat_other_comment')
     tone_intensity_score = int(excel_data.get('tone_intensity_score'))
     tone_intensity_comment = excel_data.get('tone_intensity_comment')
     dialect_area_score = int(excel_data.get('dialect_area_score'))
     dialect_area_comment = excel_data.get('dialect_area_comment')
     dialect_foreign_language_score = int(
         excel_data.get('dialect_foreign_language_score'))
     dialect_foreign_language_comment = excel_data.get(
         'dialect_foreign_language_comment')
     dialect_idiom_score = int(excel_data.get('dialect_idiom_score'))
     dialect_idiom_comment = excel_data.get('dialect_idiom_comment')
     tuning_vowel_score = int(excel_data.get('tuning_vowel_score'))
     tuning_vowel_comment = excel_data.get('tuning_vowel_comment')
     tuning_consonant_score = int(excel_data.get('tuning_consonant_score'))
     tuning_consonant_comment = excel_data.get('tuning_consonant_comment')
     tuning_mispronunciation_score = int(
         excel_data.get('tuning_mispronunciation_score'))
     tuning_mispronunciation_comment = excel_data.get(
         'tuning_mispronunciation_comment')
     tuning_nasal_score = int(excel_data.get('tuning_nasal_score'))
     tuning_nasal_comment = excel_data.get('tuning_nasal_comment')
     rhythm_speaking_rate_score = int(
         excel_data.get('rhythm_speaking_rate_score'))
     rhythm_speaking_rate_comment = excel_data.get(
         'rhythm_speaking_rate_comment')
     rhythm_speech_burst_score = int(
         excel_data.get('rhythm_speech_burst_score'))
     rhythm_speech_burst_comment = excel_data.get(
         'rhythm_speech_burst_comment')
     rhythm_other_score = int(excel_data.get('rhythm_other_score'))
     rhythm_other_comment = excel_data.get('rhythm_other_comment')
     other_incoherence_score = int(
         excel_data.get('other_incoherence_score'))
     other_incoherence_comment = excel_data.get('other_incoherence_comment')
     other_language_barrier_score = int(
         excel_data.get('other_language_barrier_score'))
     other_language_barrier_comment = excel_data.get(
         'other_language_barrier_comment')
     other_feature_score = int(excel_data.get('other_feature_score'))
     other_feature_comment = excel_data.get('other_feature_comment')
     # 新建案件
     case_name = create_case_name()
     case_id = api_object.add_case(case_name)
     # 在案件下新建文件夹
     folder_name = create_random_str()
     folder_id = api_object.add_folder(case_id, folder_name)
     # 在文件夹下上传音频
     material_file_id = api_object.upload_file_to_folder(
         case_id, file_path_1, folder_id=folder_id)
     sample_file_id = api_object.upload_file_to_folder(case_id,
                                                       file_path_2,
                                                       folder_id=folder_id)
     # 新增听觉量化分析记录
     hearing_id = api_object.add_hearing_analysis(
         material_file_id, sample_file_id, case_id, recode_state,
         pitch_level_score, pitch_level_comment,
         pitch_variation_range_score, pitch_variation_range_comment,
         pitch_model_score, pitch_model_comment, throat_allover_score,
         throat_allover_comment, throat_bubble_score, throat_bubble_comment,
         throat_other_score, throat_other_comment, tone_intensity_score,
         tone_intensity_comment, dialect_area_score, dialect_area_comment,
         dialect_foreign_language_score, dialect_foreign_language_comment,
         dialect_idiom_score, dialect_idiom_comment, tuning_vowel_score,
         tuning_vowel_comment, tuning_consonant_score,
         tuning_consonant_comment, tuning_mispronunciation_score,
         tuning_mispronunciation_comment, tuning_nasal_score,
         tuning_nasal_comment, rhythm_speaking_rate_score,
         rhythm_speaking_rate_comment, rhythm_speech_burst_score,
         rhythm_speech_burst_comment, rhythm_other_score,
         rhythm_other_comment, other_incoherence_score,
         other_incoherence_comment, other_language_barrier_score,
         other_language_barrier_comment, other_feature_score,
         other_feature_comment)
     # 将听觉量化分析记录删除
     api_object.del_hearing_analysis(case_id, material_file_id,
                                     sample_file_id)
     # 验证记录是否成功删除
     find_result = api_object.find_hearing_analysis_by_id(
         case_id, hearing_id)
     assert find_result is False