def test_login_success(api_object): """成功登录""" excel_data = read_excel('test_login_success') username = excel_data.get('username') password = excel_data.get('password') session_id = api_object.get_session_id(username, password) assert session_id
def test_remove_other_people_case(self, api_object): """测试删除其他用户的案件""" # 从excel读取数据 excel_data = read_excel('test_remove_other_people_case') target_user_group = excel_data.get('target_user_group') target_username = excel_data.get('target_username') msg = excel_data.get('msg') # 新建案件 case_name = create_case_name() case_id = api_object.add_case(case_name) # 获取用户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) # 获取分别出去的案件id target_case_name = case_name + '_' + target_username target_case_id = api_object.get_case_id(target_case_name, target_username) # 删除分别给他人的案件 res = api_object.remove_case(target_case_id) # 如果删除失败,则说明执行成功 has_error = res.get('hasError') assert has_error if has_error: # 验证删除失败的提示信息 error_desc = res.get('errorDesc') assert error_desc == msg
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)
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
def test_password_wrong(self): """密码错误登录""" excel_data = read_excel('test_password_wrong') username = excel_data.get('username') password = excel_data.get('password') msg = excel_data.get('msg') res = operate_login(username, password) error_desc = res.get('errorDesc') assert error_desc == msg
def test_username_password_none(self): """用户名、密码为空登录""" excel_data = read_excel('test_username_password_none') username = excel_data.get('username') password = excel_data.get('password') msg = excel_data.get('msg') res = operate_login(username, password) error_desc = res.get('errorDesc') assert error_desc == msg
def test_add_private_case(self, api_object): """新增私有案件""" excel_data = read_excel('test_add_private_case') private_case = bool(excel_data.get('private_case')) # 新增私有案件 case_name = create_case_name() api_object.add_case(case_name, private_case) # 查询案件是否新增成功 find_result = api_object.find_case_in_case_list(case_name) assert find_result
def test_add_same_name_case(self, api_object): """新增同名案件""" excel_data = read_excel('test_add_same_name_case') msg_keyword = excel_data.get('msg_keyword') # 新增案件 case_name = create_case_name() api_object.add_case(case_name) # 新增重复案件 error_desc = api_object.add_case(case_name) msg_check_result = error_desc.find(msg_keyword) # 验证提示信息是否正确 assert msg_check_result != -1
def test_change_password(self, api_object): """修改当前登录用户的密码""" # 从excel读取数据 excel_data = read_excel('test_change_password') username = excel_data.get('username') password = excel_data.get('password') new_password = excel_data.get('new_password') # 修改密码 user_id = api_object.get_user_id(username, password) api_object.change_password(user_id, password, new_password) # 验证新密码能否登录系统 session_id = api_object.get_session_id(username, new_password) assert session_id # 将密码进行还原 api_object.reset_password(user_id)
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
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
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
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
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