c765d9b1 by 付孟奇

自动化框架初始化,完成话术变量场景模拟

0 parents
No preview for this file type
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="111" name="Python" />
</Languages>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/SituApiSupport.iml" filepath="$PROJECT_DIR$/.idea/SituApiSupport.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
# @Time : 2022/8/23 15:13
# @Author : 付孟奇
from unittestreport import TestRunner
from util.HandleJenkins import handle_jenkins
from util.HandleData import handle_data
from config.VendorPath import base_path
import unittest
# 执行的项目文件目录
pro = handle_jenkins()['pro']
email_data = handle_jenkins()['email']
email = str(email_data).split(',')
if len(email) > 1:
email = ','.join(email)
title = handle_jenkins()['title']
env = handle_jenkins()['env']
# 执行数据库初始化
# TODO
# handle_data.db_ini()
# handle_data.handle_global()
# 执行文件地址
# TODO
suite_case = unittest.defaultTestLoader.discover(base_path + '/case/', pattern='*.py')
runner = TestRunner(suite_case,
filename="report.html",
report_dir='./report',
title=title,
tester='测试组',
desc='接口自动化测试报告',
templates=1,
pro=pro,
env=env
)
runner.run()
# runner.send_email(host="smtp.exmail.qq.com",
# port=465,
# user="fumengqi@situdata.com",
# password="Fz315824",
# to_addrs=email)
# 执行数据库清理
# TODO
# @Time : 2022/8/23 11:15
# @Author : 付孟奇
from ddt import ddt, data
from config.VendorPath import excel_path, global_path
from util.HandleJenkins import handle_jenkins
from util.HandleData import handle_data
from util.HandleSpeech import handle_speech
from util.HandleRequest import DealRequest
from util.HandleLog import logger
from util.HandleFile import file_read_save
import unittest
import json
import re
import operator
# 获取配置信息
vendor_name = handle_jenkins()['pro']
# 获取项目所有测试用例
data_list = handle_data.load_excel(excel_path, '话术变量验证')
@ddt
class DDTTest(unittest.TestCase):
@data(*data_list)
def test_case(self, data_list):
logger.info('***************【' + str(data_list['desc']) + '】接口测试开始***************')
logger.info('接口测试用例为:' + str(data_list))
# 1、设置报告的接口信息
self._testMethodName = data_list['uri']
if data_list['positive_case'] == '正向':
self._testMethodDoc = '正向case--' + data_list['desc']
elif data_list['positive_case'] == '反向':
self._testMethodDoc = '正向case--' + data_list['desc']
else:
self._testMethodDoc = data_list['desc']
# 2、参数整理
re_headers = handle_data.handle_params(data_list['headers'])
logger.info('请求头为:' + str(re_headers))
re_method = data_list['method']
re_url = handle_jenkins()['host'] + data_list['uri']
re_params = handle_data.handle_params(data_list['params'])
logger.info('请求参数为:' + str(re_params))
# 3、进行接口请求
res = DealRequest(re_method, re_url, re_headers, re_params).return_response()
logger.info('接口测试结果为:' + str(res))
# 4、响应断言
assert_num = str(data_list['response_assert']).count('话术变量验证') # 判断是否是话术场景
if assert_num == 0:
assert_data = json.loads(data_list['response_assert'])
for k in assert_data:
self.assertEqual(handle_data.get_value(res, k)[0], assert_data[k])
else: # 话术变量验证
orderRecordId = res.get('result').get('orderRecordId')
if orderRecordId is not None:
assert_msg = handle_speech.getAssert(orderRecordId)
if assert_msg['code'] ==0:
logger.info(assert_msg['msg'])
else:
raise Exception(assert_msg['msg'])
# 5、判断是否需要保存响应信息:正向case且有相应需要保存的
if res['code'] == 0:
if data_list['save_args'] != '' and data_list['positive_case'] == '正向':
list_args = re.split(r'[,,;;、.。]', data_list['save_args'])
dic_args = {}
for i in list_args:
res_args = handle_data.get_value(res, i)[0]
dic_args[i] = res_args
file_read_save(global_path, str(int(data_list['id'])), dic_args)
logger.info('***************【' + str(data_list['desc']) + '】接口测试结束***************')
if __name__ == '__main__':
unittest.main()
No preview for this file type
# @Time : 2022/8/22 15:39
# @Author : 付孟奇
import os
import time
# 项目根路径
base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 日志路径
log_path = os.path.join(base_path, 'log/{}.log'.format(time.strftime('%Y-%m-%d')))
# 公共参数文件路径
global_path = os.path.join(base_path, 'config/global_params.json')
# Excel数据路径
excel_path = os.path.join(base_path, 'data/自动化接口测试.xlsx')
# 生成报告文件路径
report_path = os.path.join(base_path, 'report/report.html')
No preview for this file type
[mysql]
;mysql_host = localhost
;mysql_port = 3306
;mysql_user = root
;mysql_passwd = fumengqi
;mysql_db = automation
mysql_host = rm-2zen60zh797n662w4lo.mysql.rds.aliyuncs.com
mysql_port = 3306
mysql_user = sanheyi_stg
mysql_passwd = x39l&Cgid150t4kvfKA
mysql_db = sanheyi_stg
\ No newline at end of file
{
"1": {
"md5": "d003784d3e6dbc116efcb6d550440465"
},
"2": {
"token": "28fbd3f975224bb995403d1bb3d36acb"
},
"3": {
"orderRecordId": 157
}
}
\ No newline at end of file
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
2022-10-17 16:34:00,037 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 16:34:00,039 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 16:34:16,574 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 16:34:16,574 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 16:35:51,541 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 16:35:51,543 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 16:37:04,101 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 16:37:04,102 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 18:09:44,684 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 18:09:44,686 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 18:11:42,848 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 18:11:42,849 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-17 18:58:25,502 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-17 18:58:25,504 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
This diff could not be displayed because it is too large.
2022-10-21 10:44:23,145 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 10:44:23,146 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 10:44:23,249 - root - INFO - 订单类型是一主一附
2022-10-21 10:46:28,083 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 10:46:28,084 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 10:46:28,148 - root - INFO - 订单类型是一主一附
2022-10-21 14:11:23,345 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 14:11:23,347 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 14:11:23,479 - root - ERROR - 测试用例打开失败,原因是:No sheet named <'字典映射'>
2022-10-21 14:11:35,370 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 14:11:35,371 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 14:11:35,480 - root - ERROR - 测试用例打开失败,原因是:No sheet named <'字典映射'>
2022-10-21 14:11:45,000 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 14:11:45,001 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 14:12:06,469 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 14:12:06,469 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:54:42,714 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:54:42,716 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:54:57,324 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:54:57,325 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:55:04,643 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:55:04,643 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:55:22,540 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:55:22,541 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:56:07,622 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:56:07,623 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:56:18,385 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:56:18,385 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:56:26,975 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:56:26,976 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:57:59,658 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:57:59,659 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 15:58:11,573 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 15:58:11,574 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:27:00,953 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:27:00,954 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:27:01,128 - root - INFO - 订单类型是一主一附
2022-10-21 17:29:04,822 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:29:04,824 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:29:04,965 - root - INFO - 订单类型是一主一附
2022-10-21 17:34:29,194 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:34:29,195 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:34:58,757 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:34:58,758 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:37:05,508 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:37:05,509 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:37:22,839 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:37:22,840 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:37:41,744 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:37:41,745 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:38:15,490 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:38:15,490 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:38:48,933 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:38:48,934 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:40:04,703 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:40:04,704 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:40:19,984 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:40:19,986 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:41:48,315 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:41:48,316 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:43:10,828 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:43:10,829 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:44:18,478 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:44:18,478 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 17:47:16,184 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 17:47:16,186 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 18:03:55,509 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 18:03:55,512 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 18:04:03,979 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 18:04:03,979 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 18:04:04,109 - root - INFO - 订单类型是一主一附
2022-10-21 18:06:03,429 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 18:06:03,429 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 18:06:23,813 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载中......
2022-10-21 18:06:23,814 - root - INFO - /Users/jingyuxiang/Desktop/code/python/SituApiSupport/config/db.ini 文件加载成功......
2022-10-21 18:06:23,935 - root - INFO - 订单类型是一主一附
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
CREATE TABLE `citic_role` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(40) CHARACTER SET utf8mb4 DEFAULT NULL,
`mark` int(11) DEFAULT NULL,
`desc` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`pid` bigint(20) DEFAULT NULL COMMENT '父id',
`path` varchar(255) DEFAULT NULL COMMENT '上级角色id完整路径',
`role_key` varchar(100) NOT NULL DEFAULT '' COMMENT '角色权限字符串',
`role_sort` int(4) NOT NULL DEFAULT '0' COMMENT '显示顺序',
`data_scope` char(1) DEFAULT '1' COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)',
`menu_check_strictly` tinyint(1) DEFAULT '1' COMMENT '菜单树选择项是否关联显示',
`organization_check_strictly` tinyint(1) DEFAULT '1' COMMENT '部门树选择项是否关联显示',
`status` char(1) NOT NULL DEFAULT '0' COMMENT '角色状态(0正常 1停用)',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`extra_info` varchar(500) DEFAULT NULL COMMENT '附加信息',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
\ No newline at end of file
CREATE TABLE `citic_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(45) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '工号',
`password` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`name` varchar(30) CHARACTER SET utf8mb4 DEFAULT NULL,
`telephone` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL,
`activate` tinyint(4) DEFAULT NULL COMMENT '1 = 已激活, 2 = 未激活, 3 = 已禁用',
`org_code` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '组织机构代码',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
`activate_time` datetime DEFAULT NULL,
`branch_id` bigint(20) DEFAULT NULL COMMENT '分公司_id',
`branch_name` varchar(45) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '分公司_name',
`sub_branch_id` bigint(20) DEFAULT NULL COMMENT '支公司_id',
`sub_branch_name` varchar(45) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '支公司_name',
`marketing_channel` varchar(45) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '营销渠道',
`departed` tinyint(4) DEFAULT NULL COMMENT '是否离职 1 = 离职 2 = 在职',
`user_type` tinyint(4) DEFAULT NULL COMMENT '1 = app端 2 = web端(信诚) 3 = web端(思图)',
`last_login_time` datetime DEFAULT NULL COMMENT '最后一次登录时间',
`directly_agency_id` bigint(11) DEFAULT NULL COMMENT '直属机构id',
`directly_agency_name` varchar(45) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '直属机构名字',
`id_card` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '身份证',
`licensed` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '职业证',
`open_id` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '微信号',
`emp_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '业务员工号',
`extra_info` text CHARACTER SET utf8mb4 COMMENT '额外信息',
`email` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`employee_id` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '工号',
`source` tinyint(4) DEFAULT NULL COMMENT '用户来源:1=本地注册,2=统一登录获取',
`group_id` bigint(20) DEFAULT NULL COMMENT '团队id',
`company_name` varchar(225) CHARACTER SET utf8mb4 DEFAULT '' COMMENT '销售人员所属中介公司名称',
`company_code` varchar(50) DEFAULT NULL COMMENT '销售人员所属经代公司编码',
`cert_type` varchar(4) DEFAULT NULL COMMENT '证件类型',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=8204 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
\ No newline at end of file
CREATE TABLE `citic_user_role` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) DEFAULT NULL,
`role_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=8188 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
\ No newline at end of file
File mode changed
CREATE TABLE `order_base_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`task_id` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '双录任务号',
`order_id` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '电子订单号',
`policy_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '保单号',
`serial_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '字纸投保单流水号',
`self_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '保全订单号',
`customer_name` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '投保人姓名',
`customer_id_card_type` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '投保人证件类型',
`customer_num` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`product_type` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '产品类型',
`ptt_id` bigint(20) DEFAULT NULL COMMENT '产品模板id',
`product_name` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '产品名称',
`product_code` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '产品编号',
`pr_id` bigint(20) DEFAULT NULL COMMENT '产品表主键id',
`organization_name` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '管理机构名称',
`org_id` bigint(20) DEFAULT NULL COMMENT '管理机构表主键id(支公司机构id)',
`quality_audit_status` int(11) DEFAULT '0' COMMENT '质检状态(1 = 未录制 , 2 =质检中,3 =已质检)',
`quality_audit_count` int(11) DEFAULT '0' COMMENT '质检次数',
`upload_time` datetime DEFAULT NULL COMMENT '最后一次上传时间',
`recording_time` int(11) DEFAULT NULL COMMENT '录制时间',
`recording_people` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '录制人',
`quality_audit_advice` int(11) DEFAULT '0' COMMENT '质检结果 (0 = 待质检,1 = 通过,2 = 重录,3 = 补录)',
`ac_id` bigint(20) DEFAULT NULL COMMENT '账户id',
`top_org_id` bigint(20) DEFAULT NULL COMMENT '顶级机构表id',
`extra_info` text CHARACTER SET utf8mb4 COMMENT '额外话术模板变量信息',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`life_cycle` tinyint(4) DEFAULT NULL COMMENT '1、被覆盖。2、创建(无效)。3、待录制(生效)。11、驳回补录。12、驳回重录。13、首次提交。14、审核通过。15. 已完成 21、首次可质检。22、补录提交。23、重录提交。',
`lock_order` int(10) DEFAULT '2' COMMENT '订单锁定状态(1 = 锁定, 2 = 未锁定)',
`order_no_type` int(11) DEFAULT NULL COMMENT '1 = 电子订单号,2 = 纸质投保单流水号',
`salesman_username` varchar(40) CHARACTER SET utf8mb4 DEFAULT '' COMMENT '录制人工号',
`marketing_channel` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '营销渠道',
`need_tts` int(11) DEFAULT NULL COMMENT '1 = 开启; 2= 关闭',
`salesman_id` bigint(20) DEFAULT NULL COMMENT '营销员ID',
`org_code` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '组织机构代码',
`branch_id` bigint(20) DEFAULT NULL COMMENT '分公司机构管理id',
`recording_begin_time` bigint(20) DEFAULT NULL COMMENT '录制开始时间',
`appnt_age` varchar(20) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '投保人年龄',
`encrypt_key` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
`insure_self` int(11) DEFAULT NULL COMMENT '自保件/非自保件(1 = 自保件;2 = 非自保件;)',
`support_remote` int(11) DEFAULT '2' COMMENT '是否支持远程(1 = 支持;2 = 不支持;)',
`system_type` int(11) DEFAULT '1' COMMENT '双录类型(1 = 现场;2 = 远程;)',
`mixed_flow_status` int(11) DEFAULT '1' COMMENT '混流状态(1 = 完成;2 = 处理中;...)',
`record_rs` int(11) DEFAULT NULL COMMENT '选中需要质检(1 = 选中, 2= 未选中)',
`hesitate_period` int(11) DEFAULT NULL COMMENT '真正的犹豫期',
`hesitate_period_history` int(11) DEFAULT NULL COMMENT '如果打开开关,那么这个列存开关之前的犹豫期\r\n如果关闭开关,把此项清空,然后把这个项的值拿到真的犹豫期里面',
`order_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`cont_no` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL,
`first_recording_begin_time` bigint(20) DEFAULT NULL COMMENT '首次录制时间',
`apply_date` date DEFAULT NULL COMMENT '投保申请日期',
`gender` int(11) DEFAULT NULL COMMENT '1 = 男 2 = 女',
`order_source` int(11) DEFAULT '1' COMMENT '1 = 电子订单号(扫码录入),2 = 纸质投保单流水号(手工录入), 3 = 系统对接,4=跳转入件',
`redress_status` int(10) DEFAULT '2' COMMENT '订单是否被复审人员更正过(1 = 更正, 2 = 未更正)',
`version_code` varchar(16) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '二维码版本号',
`audit_source` int(11) DEFAULT NULL COMMENT '质检抽样结果 1=抽样质检,2=强制通过 > X质检,3=自动通过',
`quota_type` int(5) DEFAULT NULL COMMENT '保全项:1-新增附加险,2-变更投保人',
`record_type` int(5) DEFAULT NULL COMMENT '双录类型:1-新契约,2-保全',
`applicant_remote_flag` int(11) DEFAULT NULL COMMENT '投保人远程标志 : 1:允许远程 2:不允许远程',
`many_insures_flag` int(11) DEFAULT NULL COMMENT '多被保人标志 0:单被保人 1:多被保人',
`same_person` int(11) DEFAULT NULL COMMENT '投被保人是否为同一人标志 1:同一人 2:不同人',
`lock_expire_time` datetime DEFAULT NULL COMMENT '订单锁定过期时间',
`system_source` varchar(10) DEFAULT NULL COMMENT '系统来源:1-经英宝,2-微信公众号',
`insurance_company` varchar(20) DEFAULT NULL COMMENT '保司来源',
`sign_order_status` tinyint(4) DEFAULT '0' COMMENT '签单状态(0-未签单,1-已签单)',
`correction_status` int(11) DEFAULT '0' COMMENT '更正状态 0 = 默认不用更正(电子/比对一致的); 1 = 已更正; 2 = 未更正;',
PRIMARY KEY (`id`) USING BTREE,
KEY `life_cycle_index` (`life_cycle`) USING BTREE,
KEY `order_id_index` (`order_id`) USING BTREE,
KEY `policy_no_index` (`policy_no`) USING BTREE,
KEY `serial_no_index` (`serial_no`) USING BTREE,
KEY `create_time_index` (`create_time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 COMMENT='订单主表';
\ No newline at end of file
CREATE TABLE `speech_variable` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`name` varchar(32) NOT NULL DEFAULT '' COMMENT '变量名称',
`desc` varchar(64) NOT NULL DEFAULT '' COMMENT '变量描述',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '变量排序值:根据sort排序',
`group_id` int(11) NOT NULL DEFAULT '0' COMMENT '变量所属组ID',
`level` int(11) NOT NULL DEFAULT '1' COMMENT '变量所属组层级',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
`deleted` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否删除:0-被删除,1-正常',
`available` smallint(6) NOT NULL DEFAULT '1' COMMENT '是否可用:0-不可用,1-可用',
`display` smallint(6) NOT NULL DEFAULT '1' COMMENT '是否显示:0-不显示,1-显示',
`record_type` smallint(6) DEFAULT '3' COMMENT '1-新契约, 2-保全, 3-共同属性',
`extra_info` varchar(255) DEFAULT NULL COMMENT '额外描述信息',
PRIMARY KEY (`id`) USING BTREE,
KEY `deleted_index` (`deleted`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8mb4 COMMENT='话术变量表';
\ No newline at end of file
# @Time : 2022/8/30 16:28
# @Author : 付孟奇
from config.VendorPath import base_path
from util.HandleFile import load_ini_file
from util.HandleLog import logger
import os
import pymysql
db_file_path = os.path.join(base_path, 'config', 'db.ini')
class DBLoad:
def __init__(self):
db_res = load_ini_file(db_file_path, 'mysql')
self.DB_CONF = {
'host': db_res['mysql_host'],
'port': int(db_res['mysql_port']),
'user': db_res['mysql_user'],
'passwd': db_res['mysql_passwd'],
'db': db_res['mysql_db'],
}
self.connect()
def connect(self, db_conf=None):
# 通过字典拆包传递配置信息,建立数据库连接
if db_conf is None:
db_conf = self.DB_CONF
self.conn = pymysql.connect(**db_conf, autocommit=True)
# 通过 cursor() 创建游标对象,并让查询结果以字典格式输出
self.cur = self.conn.cursor(cursor=pymysql.cursors.DictCursor)
def select_db(self, sql):
"""查询"""
# 检查连接是否断开,如果断开就进行重连
self.conn.ping(reconnect=True)
# 使用 execute() 执行sql
self.cur.execute(sql)
# 使用 fetchall() 获取查询结果
data = self.cur.fetchall()
return data
def execute_db(self, sql):
"""更新/新增/删除"""
try:
# 检查连接是否断开,如果断开就进行重连
self.conn.ping(reconnect=True)
# 使用 execute() 执行sql
self.cur.execute(sql)
# 提交事务
self.conn.commit()
except Exception as e:
logger.info("操作MySQL出现错误,错误原因:{}".format(e))
# 回滚所有更改
self.conn.rollback()
db_load = DBLoad()
# @Time : 2022/8/23 14:45
# @Author : 付孟奇
from util.HandleLog import logger
from util.HandleFile import file_read_global
import xlrd
import json
class DateLoad:
# 读取Excel数据--按行
def load_excel(self, file, tag):
data_list = []
try:
book = xlrd.open_workbook(file)
tag = book.sheet_by_name(tag)
# 获取行数
row_num = tag.nrows
header = tag.row_values(0)
for i in range(1, row_num):
# 读取行
row_data = tag.row_values(i)
# 读取行中的每一列的值
d = dict(zip(header, row_data))
data_list.append(d)
return data_list
except Exception as e:
logger.error('测试用例打开失败,原因是:%s' % e)
# 查找特定key的value信息
def get_value(self, source_json, object_key):
result = []
if isinstance(source_json, dict) and object_key in source_json.keys():
value = source_json[object_key]
result.append(value)
return result
elif isinstance(source_json, (list, tuple)):
for item in source_json:
value = self.get_value(item, object_key)
if value == "None" or value is None:
pass
elif len(value) == 0:
pass
else:
result.append(value)
return result
else:
if isinstance(source_json, dict):
for k in source_json:
value = self.get_value(source_json[k], object_key)
if value == "None" or value is None:
pass
elif len(value) == 0:
pass
else:
for item in value:
result.append(item)
return result
# 处理请求的可变参数
def handle_params(self, args):
try:
if str(args).count('话术变量验证') == 1: # 话术变量场景测试参数特殊处理
from util.HandleSpeech import handle_speech
params_list = str(args).split('-')
args = handle_speech.getRestult(params_list[1])
return json.loads(args)
elif args[0] == '{':
args = json.loads(args)
old_key = [] # 变量的key的集合
old_value = [] # 变量集合
# 遍历请求参数中,所有的变量信息
for k, v in args.items():
if str(v)[0] == '#':
old_key.append(k)
old_value.append(v)
# 替换变量值
if len(old_value) != 0:
logger.info('需要替换的变量信息为:' + str(old_value))
key_dic = {}
for i in old_value:
v_key = str(i[1:]).split('.')
res = file_read_global(v_key)
key_dic[i] = res
logger.info('可变参数的信息为:' + str(key_dic))
# 参数替换
for j in key_dic:
self.dic_del(args, j, key_dic)
logger.info('可变参数替换完毕:' + str(args))
return args
else:
return ''
except:
return {'code': 1, 'result': '参数错误,请检查替换信息是否正确'}
# json格式字典处理
def dic_del(self, data_json, data_key, key_dic):
if isinstance(data_json, dict):
for k, v in data_json.items():
if v == data_key:
data_json[k] = key_dic[data_key]
else:
self.dic_del(v, data_key, key_dic)
elif isinstance(data_json, list):
for i in data_json:
self.dic_del(i, data_key, key_dic)
handle_data = DateLoad()
if __name__ == '__main__':
handle_data.handle_global()
# @Time : 2022/8/24 16:07
# @Author : 付孟奇
from config.VendorPath import global_path
from util.HandleLog import logger
import configparser
import json
import base64
import yaml
# 读取ini文件内容
def load_ini_file(file_path, sec):
logger.info("{} 文件加载中......".format(file_path))
config = configparser.ConfigParser()
config.read(file_path, encoding="UTF-8")
data = dict(config[sec])
logger.info("{} 文件加载成功......".format(file_path))
return data
# 读取yaml文件内容
def load_yaml_file(file_path):
logger.info("{} 文件加载中......".format(file_path))
with open(file_path, encoding='utf-8') as f:
data = yaml.safe_load(f)
logger.info("{} 文件加载成功......".format(file_path))
return data
# 读取json文件并重新存储
def file_read_save(file_path, file_key, file_value):
with open(file_path, 'r+') as f:
file_data = json.load(f)
file_data[str(file_key)] = file_value
f.seek(0)
f.truncate()
json.dump(file_data, f, indent=4, ensure_ascii=False)
logger.info('响应信息存储完毕!!!')
# 读取公共参数文件指定内容
def file_read_global(args):
with open(global_path, 'r') as f:
file_data = json.load(f)
res = file_data[args[0]][args[1]]
return res
# 读取图片转换64
def file_base_64(path):
with open(path, 'rb') as f:
base64_data = base64.b64encode(f.read())
data = base64_data.decode()
return data
# @Time : 2022/10/31 18:14
# @Author : 付孟奇
from util.HandleFile import load_yaml_file
from util.HandleDB import db_load
from config.VendorPath import base_path, global_path
import os
import json
ddl_file_path = os.path.join(base_path, 'sql', 'speech_variable.yaml')
class InitLoad:
def __init__(self):
print('111')
# 初始化数据库
def db_ini(self):
# 加载数据库建表SQL
res_yaml = load_yaml_file(ddl_file_path)
# 执行插入SQL
db_load.execute_db(res_yaml)
self.handle_global()
# 清空公共参数文件内容
def handle_global(self):
data = {}
json.dump(data, open(global_path, 'w'), indent=4)
handle_init = InitLoad()
if __name__ == '__main__':
handle_init.handle_global()
# @Time : 2022/8/22 15:40
# @Author : 付孟奇
import sys
'''
1、项目名称
2、项目环境
3、当前环境域名
4、邮件发送地址
5、邮件名称
6、联系人电话
'''
def handle_jenkins():
config_info = {}
# Jenkins参数
if len(sys.argv) > 1:
config_info['pro'] = sys.argv[1]
config_info['env'] = sys.argv[2]
config_info['host'] = sys.argv[3]
config_info['email'] = sys.argv[4]
config_info['title'] = sys.argv[5]
else:
# 本地兼容
config_info['pro'] = '话术变量'
config_info['env'] = 'staging'
config_info['host'] = 'https://staging-moonlight-life-video.situdata.com' # https://staging-moonlight-life-video.situdata.com
config_info['email'] = 'fumengqi@situdata.com'
config_info['title'] = '本地调试'
config_info['phone'] = '15737319294'
return config_info
# @Time : 2022/8/22 15:37
# @Author : 付孟奇
import logging
from config.VendorPath import log_path
class Log:
def insert_log(self, level, message):
# 创建一个logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# 创建一个handler,用于写入日志文件
fh = logging.FileHandler(log_path, 'a', encoding='utf-8')
fh.setLevel(logging.DEBUG)
# 再创建一个handler,用于输出到控制台
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# 定义handler的输出格式
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
# 给logger添加handler
logger.addHandler(fh)
logger.addHandler(ch)
# 记录一条日志
if level == 'info':
logger.info(message)
elif level == 'debug':
logger.debug(message)
elif level == 'warning':
logger.warning(message)
elif level == 'error':
logger.error(message)
logger.removeHandler(ch)
logger.removeHandler(fh)
# 关闭打开的文件
fh.close()
def debug(self, message):
self.insert_log('debug', message)
def info(self, message):
self.insert_log('info', message)
def warning(self, message):
self.insert_log('warning', message)
def error(self, message):
self.insert_log('error', message)
logger = Log()
# @Time : 2022/8/24 11:40
# @Author : 付孟奇
from requests import Timeout, RequestException
import requests
class DealRequest:
def __init__(self, method, url, headers, params):
self.method = method
self.url = url
self.headers = headers
self.params = params
def return_response(self):
return self.res_request()
def res_request(self):
if self.method == 'POST':
res = self.res_post(self.url, self.headers, self.params)
elif self.method == "GET":
res = self.res_get(self.url, self.headers, self.params)
elif self.method == "PUT":
res = self.res_put(url=self.url, params=self.params)
elif self.method == "DELETE":
res = self.res_delete(url=self.url, params=self.params, headers=self.headers)
else:
res = {'code': 1, 'result': '接口请求失败,当前请求方式不支持'}
return res
def res_post(self, url, headers, params):
try:
res = requests.request('POST', url, headers=headers, json=params)
if res.status_code == 200:
return res.json()
else:
return {'code': 1, 'result': '接口请求失败,返回状态码:%s' % str(res.status_code)}
except Timeout as e:
return {'code': 1, 'result': '请求超时:%s' % e}
except RequestException as e:
return {'code': 1, 'result': '请求异常:%s' % e}
except Exception as e:
return {'code': 1, 'result': 'post请求出错,出错原因:%s' % e}
def res_get(self, url, headers, params):
try:
if params == '':
res = requests.get(url, headers=headers)
else:
res = requests.get(url, headers=headers, params=params)
if res.status_code == 200:
return res.json()
else:
return {'code': 1, 'result': '接口请求失败,返回状态码:%s' % str(res.status_code)}
except Timeout as e:
return {'code': 1, 'result': '请求超时:%s' % e}
except RequestException as e:
return {'code': 1, 'result': '请求异常:%s' % e}
except Exception as e:
return {'code': 1, 'result': 'get请求出错,出错原因:%s' % e}
def res_put(self, url, params):
try:
r = requests.put(url, params=params)
except Timeout as e:
return {'code': 1, 'result': '请求超时:%s' % e}
except RequestException as e:
return {'code': 1, 'result': '请求异常:%s' % e}
except Exception as e:
return {'code': 1, 'result': 'put请求出错,出错原因:%s' % e}
def res_delete(self, url, headers, params):
try:
r = requests.delete(url, headers=headers, params=params)
except Timeout as e:
return {'code': 1, 'result': '请求超时:%s' % e}
except RequestException as e:
return {'code': 1, 'result': '请求异常:%s' % e}
except Exception as e:
return {'code': 1, 'result': 'delete请求出错,出错原因:%s' % e}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!