Commit 6a94d344 authored by huangqiang's avatar huangqiang

第一次提交

parent 3a6077cc
<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"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7 (GeekInterfaceTest)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="pytest" />
</component>
</module>
\ 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 (GeekInterfaceTest)" 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/jk_interface_test.iml" filepath="$PROJECT_DIR$/.idea/jk_interface_test.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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="54f4d37d-1724-4813-a1e2-24e200088c5f" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1nPqpGaEWLImTlIS6FQ5yJzJajR" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PythonContentEntriesConfigurable" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="54f4d37d-1724-4813-a1e2-24e200088c5f" name="Default Changelist" comment="" />
<created>1611302255574</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1611302255574</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state x="360" y="197" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1611302358176">
<screen x="0" y="23" width="1792" height="1017" />
</state>
<state x="360" y="197" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.23.1792.1017@0.23.1792.1017" timestamp="1611302358176" />
<state x="683" y="296" key="FileChooserDialogImpl" timestamp="1611303152470">
<screen x="0" y="23" width="1792" height="1017" />
</state>
<state x="683" y="296" key="FileChooserDialogImpl/0.23.1792.1017@0.23.1792.1017" timestamp="1611303152470" />
<state x="397" y="173" key="SettingsEditor" timestamp="1611303202671">
<screen x="0" y="23" width="1792" height="1015" />
</state>
<state x="397" y="173" key="SettingsEditor/0.23.1792.1015@0.23.1792.1015" timestamp="1611303202671" />
<state x="397" y="173" key="SettingsEditor/0.23.1792.1017@0.23.1792.1017" timestamp="1611302888504" />
</component>
</project>
\ No newline at end of file
# coding:utf-8
import string
import traceback
def replace_string(template_str: str, variable_dict: dict):
template = string.Template(template_str)
return template.safe_substitute(**variable_dict)
def result_calculate(pass_num, fail_num):
pass_num = float(pass_num)
fail_num = float(fail_num)
count_num = pass_num + fail_num
# 90%
if count_num:
pass_rate = "%.2f%%" % (pass_num / count_num * 100)
fail_rate = "%.2f%%" % (fail_num / count_num * 100)
else:
pass_rate = "-"
fail_rate = "-"
return pass_rate, fail_rate
def get_time_diff(start, end):
diff = str((end-start).seconds) + "s"
return diff
def get_page_num(page_number, page_size):
try:
page_number = int(page_number) if int(page_number) >= 1 else 1
page_size = int(page_size) if int(page_size) >= 1 else 10
start_num = int((page_number - 1) * page_size)
end_num = int(start_num + page_size)
except ValueError as e:
print("page_num: %s,page_size:%s,格式错误" % (page_number, page_size))
traceback.print_exc()
start_num = 0
end_num = 10
return start_num, end_num
# coding=utf-8
import psycopg2
class OperationDb:
def __init__(self, database_config: dict):
self.database_config = database_config
def query_sql(self, sql_str):
# 创建连接对象
conn = psycopg2.connect(**self.database_config)
cur = conn.cursor() # 创建指针对象
try:
cur.execute(sql_str)
results = cur.fetchall()
finally:
conn.commit()
cur.close()
conn.close()
print('查询结束')
return results
if __name__ == "__main__":
sql = """select student_id,student_name from service_profile.student limit 10"""
opd = OperationDb("../data/config/config.conf").query_sql(sql)
print(opd)
# coding:utf-8
import xlrd
import xlwt
from xlutils.copy import copy
import os
class OperationExcel:
def __init__(self, file_name, sheet_name):
if file_name:
self.file_name = file_name
self.sheet_name = sheet_name
else:
print("excel的路径和sheetname不能为空", file_name, sheet_name)
# 获取sheets的内容
def get_sheet(self):
data = xlrd.open_workbook(self.file_name, encoding_override="utf-8")
tables = data.sheet_by_name(self.sheet_name)
return tables
# 获取单元格的行数
def get_lines(self):
tables = self.get_sheet()
return tables.nrows
# 获取某一个单元格的内容
def get_cell_value(self, row, col):
return self.get_sheet().cell_value(row, col)
# 根据data,列号,找到找到对应行的内容
def get_row_datas(self, data, col_id):
row_nums = self.get_row_num(data, col_id)
rows_datas = self.get_row_values(row_nums)
return rows_datas
# 根据对应的1个内容找到对应的行号
def get_row_num(self, data, col_id):
nums = []
num = 0
cols_data = self.get_cols_data(col_id)
for col_data in cols_data:
if data == col_data:
nums.append(num)
num = num + 1
return nums
# 根据行号,找到该行的内容
def get_row_values(self, row_nums):
tables = self.get_sheet()
row_datas = []
for num in row_nums:
row_data = tables.row_values(num)
row_datas.append(row_data)
return row_datas
# 获取某一列的内容
def get_cols_data(self, col_id):
if col_id:
cols = self.get_sheet().col_values(col_id)
else:
cols = self.get_sheet().col_values(0)
return cols
if __name__ == '__main__':
pass
# opers = OperationExcel()
# print(opers.get_cell_value(1, 2))
# coding:utf-8
import json
import jsonpath
class OperetionJson:
# 读取json文件
def read_data(self, file_path):
with open(file_path, "r", encoding="utf-8") as fp:
data = json.load(fp)
return data
# 根据关键字获取数据
def get_data(self, id, data):
print(type(data))
return data[id]
# 写json
def write_data(self, file_path, data):
with open(file_path, 'w', encoding="utf-8") as fp:
fp.write(json.dumps(data))
if __name__ == '__main__':
opj = OperetionJson()
json_string = opj.read_data("test_json.json")
print(jsonpath.jsonpath(json_string, "$.data.content[0,1,2].courseIds"))
# coding=utf-8
import logging
import time
import os
class Log(object):
"""封装后的logging"""
def __init__(self, logger=None, file_dir=os.getcwd() + "/log/"):
"""
指定保存日志的文件路径,日志级别,以及调用文件
将日志存入到指定的文件中
"""
# 创建一个logger
self.logger = logging.getLogger(logger)
self.logger.setLevel(logging.DEBUG)
# 创建一个handler,用于写入日志文件
self.log_time = time.strftime("%Y_%m_%d")
if not os.path.exists(file_dir):
os.mkdir(file_dir)
self.log_path = file_dir
self.log_name = self.log_path + self.log_time + '_run.log'
# self.log_name = self.log_path + 'run.log'
# print(self.log_name)
fh = logging.FileHandler(self.log_name, 'a', encoding='utf-8') # 这个是python3的"
fh.setLevel(logging.INFO)
# 再创建一个handler,用于输出到控制台
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
# 定义handler的输出格式
formatter = logging.Formatter(
'[%(asctime)s] %(filename)s->%(funcName)s line:%(lineno)d [%(levelname)s] %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
# 给logger添加handler
self.logger.addHandler(fh)
self.logger.addHandler(ch)
# 关闭打开的文件
fh.close()
ch.close()
# 添加下面一句,在记录日志之后移除句柄
# self.logger.removeHandler(ch)
# self.logger.removeHandler(fh)
@staticmethod
def get_logger(module_name):
return Log(module_name).logger
if __name__ == '__main__':
h = lambda x: x.split("run.")[1]
print(h("run.log"))
import datetime
import time
from datetime import timedelta
class GetTime:
@staticmethod
def get_current_time():
current_now = datetime.datetime.now()
current_time = current_now.strftime("%Y-%m-%d %H:%M:%S")
current_time_num = int(time.time() * 1000)
return {"current_time": current_time, "current_time_num": current_time_num}
@staticmethod
def get_today():
current_time = datetime.datetime.now()
today_start = current_time.strftime("%Y-%m-%d 00:00:00")
today_end = current_time.strftime("%Y-%m-%d 23:59:59")
today_date = current_time.strftime("%Y-%m-%d")
return {"today_start": today_start, "today_end": today_end, "today_date": today_date}
@staticmethod
def get_this_week():
current_time = datetime.datetime.now()
this_week_start = current_time - timedelta(days=current_time.weekday())
this_week_end = current_time + timedelta(days=(6-current_time.weekday()))
this_week_start_date = this_week_start.strftime("%Y-%m-%d")
this_week_start_time = this_week_start.strftime("%Y-%m-%d 00:00:00")
this_week_end_date = this_week_end.strftime("%Y-%m-%d")
this_week_end_time = this_week_end.strftime("%Y-%m-%d 23:59:59")
return {
"this_week_start_date": this_week_start_date,
"this_week_end_date": this_week_end_date,
"this_week_start_time": this_week_start_time,
"this_week_end_time": this_week_end_time,
}
@staticmethod
def get_this_month():
current_time = datetime.datetime.now()
this_month_start = datetime.datetime(current_time.year, current_time.month, 1)
this_month = current_time.month
print(this_month)
if this_month == 12:
this_month_start_date = f"{current_time.year}-12-01"
this_month_start_time = f"{current_time.year}-12-01 00:00:00"
this_month_end_date = f"{current_time.year}-12-31"
this_month_end_time = f"{current_time.year}-12-31 23:59:59"
else:
this_month_end = datetime.datetime(current_time.year, current_time.month + 1, 1) - timedelta(days=1)
this_month_start_date = this_month_start.strftime("%Y-%m-%d")
this_month_start_time = this_month_start.strftime("%Y-%m-%d 00:00:00")
this_month_end_date = this_month_end.strftime("%Y-%m-%d")
this_month_end_time = this_month_end.strftime("%Y-%m-%d 23:59:59")
return {
"this_month_start_date": this_month_start_date,
"this_month_end_date": this_month_end_date,
"this_month_start_time": this_month_start_time,
"this_month_end_time": this_month_end_time,
}
@staticmethod
def get_today_before(num):
current_time = datetime.datetime.now()
n_tian_qian = current_time - timedelta(days=num)
before_time = n_tian_qian.strftime("%Y-%m-%d 00:00:00")
before_date = n_tian_qian.strftime("%Y-%m-%d")
return {
f"before_date_{num}": before_date,
f"before_time_{num}": before_time
}
@staticmethod
def get_today_after(num):
current_time = datetime.datetime.now()
n_tian_hou = current_time + timedelta(days=num)
after_time = n_tian_hou.strftime("%Y-%m-%d 23:59:59")
after_date = n_tian_hou.strftime("%Y-%m-%d")
return {
f"after_date_{num}": after_date,
f"after_time_{num}": after_time
}
@staticmethod
def get_all():
return {**GetTime.get_today(),
**GetTime.get_current_time(),
**GetTime.get_this_month(),
**GetTime.get_this_week(),
**GetTime.get_today_after(7),
**GetTime.get_today_before(1),
**GetTime.get_today_before(7),
**GetTime.get_today_before(30)
}
# now = datetime.datetime.now()
# # 今天
# today = now.strftime("%Y-%m-%d %H:%M:%S")
# print("今天")
# print(today)
# # 昨天
# yesterday = now - timedelta(days=1)
# print("昨天")
# print(yesterday)
# # 明天
# tomorrow = now + timedelta(days=1)
# print("明天")
# print(tomorrow)
# 当前季度
# now_quarter = now.month/3 if now.month % 3 == 0 else now.month / 3 + 1
# print("当前季度")
# print(now_quarter)
#
# # 上周第一天和最后一天
# last_week_start = now - timedelta(days=now.weekday() + 7)
# last_week_end = now - timedelta(days=now.weekday() + 1)
# print("上周第一天和最后一天")
# print(last_week_start, last_week_end)
#
#
# # 上月第一天和最后一天
# last_month_end = this_month_start - timedelta(days=1)
# last_month_start = datetime.datetime(last_month_end.year, last_month_end.month, 1)
# print("上月第一天和最后一天")
# print(last_month_start, last_month_end)
#
# # 本季第一天和最后一天
# month = (now.month - 1) - (now.month - 1) % 3 + 1
# this_quarter_start = datetime.datetime(now.year, month, 1)
# this_quarter_end = datetime.datetime(now.year, month + 3, 1) - timedelta(days=1)
# print("本季第一天和最后一天")
# print(this_quarter_start, this_quarter_end)
#
# # 上季第一天和最后一天
# last_quarter_end = this_quarter_start - timedelta(days=1)
# last_quarter_start = datetime.datetime(last_quarter_end.year, last_quarter_end.month - 2, 1)
# print("上季第一天和最后一天")
# print(last_quarter_start, last_quarter_start)
#
# # 本年第一天和最后一天
# this_year_start = datetime.datetime(now.year, 1, 1)
# this_year_end = datetime.datetime(now.year + 1, 1, 1) - timedelta(days=1)
# print("本年第一天和最后一天")
# print(this_year_start, this_year_end)
#
# # 去年第一天和最后一天
# last_year_end = this_year_start - timedelta(days=1)
# last_year_start = datetime.datetime(last_year_end.year, 1, 1)
# print("去年第一天和最后一天")
# print(last_year_start, last_year_end)
if __name__ == "__main__":
# print(GetTime.get_today_start_end())
# print(GetTime.get_this_month())
# print(GetTime.get_today_before(5))
# print(GetTime.get_today_after(5))
print(GetTime.get_all())
# coding:utf-8
import requests
import time
import traceback
from json.decoder import JSONDecodeError
from urllib3.connectionpool import InsecureRequestWarning
import urllib3
urllib3.disable_warnings(InsecureRequestWarning)
from common.operation_log import Log
log = Log.get_logger(__name__)
class RunMethod:
@staticmethod
def run_main(run_method, url, params=None, body_data=None, header=None, wait_time=None, time_out=60, **kwargs):
try:
if wait_time:
print(f"开启等待时间{wait_time}")
time.sleep(int(wait_time))
if run_method == 'POST':
res = requests.post(url, json=body_data, params=params, headers=header, timeout=time_out, verify=False)
elif run_method == 'GET':
res = requests.get(url, params=params, headers=header, timeout=time_out, verify=False)
elif run_method == 'PUT':
res = requests.put(url, json=body_data, params=params, headers=header, timeout=time_out, verify=False)
elif run_method == 'DELETE':
res = requests.delete(url, json=body_data, params=params, headers=header, timeout=time_out, verify=False)
elif run_method == 'HEAD':
res = requests.head(url, params=params, headers=header, timeout=time_out, verify=False)
elif run_method == 'PATCH':
res = requests.patch(url, json=body_data, params=params, headers=header, timeout=time_out, verify=False)
else:
res = requests.request(method=run_method, url=url, json=body_data, params=params, headers=header, timeout=time_out, verify=False)
res_headers = res.headers
try:
res_j = res.json()
except JSONDecodeError as e:
log.info("请求返回的接口格式错误:%s" % repr(e))
res_j = {"res": res.text}
except Exception as e:
log.info("其他未知异常:%s" % repr(e))
traceback.print_exc()
res_j = {}
res_headers = {}
return res_j, res_headers
if __name__ == "__main__":
pass
# coding=utf-8
from dingtalkchatbot import chatbot
from common import common_util
class SendDingDindMsg:
def __init__(self, web_hook, msg):
self.web_hook = web_hook
self.msg = msg
def send_dingding_message(self, message_type="text", is_at_all=False, at_mobiles=None):
result = None
ding_robot = chatbot.DingtalkChatbot(self.web_hook)
if message_type == "text":
if isinstance(self.msg, str):
result = ding_robot.send_text(msg=self.msg, is_at_all=is_at_all, at_mobiles=at_mobiles)
elif message_type == "link":
# msg={title="测试标题",text="this is 内容",message_url="http://132.232.15.12/jky/#/personnel/employeeinfo"}
if isinstance(self.msg, dict):
result = ding_robot.send_link(**self.msg)
else:
print("msg数据类型错误")
elif message_type == "markdown":
# msg={title="测试标题",text="this is 内容"}
if isinstance(self.msg, dict):
title = self.msg['title']
text = self.msg['text']
result = ding_robot.send_markdown(title=title, text=text, is_at_all=is_at_all, at_mobiles=at_mobiles)
else:
print("msg数据类型错误")
elif message_type == "send_feed_card":
if isinstance(self.msg, list):
links = []
# title = "测试feedcard",message_url = "http://132.232.15.12/jky/#/personnel/employeeinfo",\
# pic_url="http://pic18.nipic.com/20120103/8993051_170340691334_2.jpg"
for m in self.msg:
if isinstance(m, dict):
link = chatbot.FeedLink(**m)
links.append(link)
else:
print("msg中有类型错误")
if links:
result = ding_robot.send_feed_card(links=links)
else:
print("msg数据类型错误")
elif message_type == "ActionCard":
if isinstance(self.msg, dict):
action_card = chatbot.ActionCard(**self.msg)
result = ding_robot.send_action_card(action_card)
else:
print("msg数据类型错误")
else:
print("msg_type错误")
return result
def get_markdown_template() -> str:
markdown_template = """
接口测试概要(${host})
测试系统:${test_sys}
测试模块:${test_modules}
整体结果: ${result_all}
测试开始时间:${start_time}
测试结束时间:${end_time}
持续时间:${duration}
测试接口总数:${total}
成功:${success_num} || 失败:${fail_num}
测试成功率:${success_rate}
测试失败率:${fail_rate}
"""
return markdown_template
def send_result_message(summary: dict, web_hook):
result = summary["result"]
result_all = summary["result_all"]
time = summary["time"]
message_data = {
"host": summary["host"],
"result_all": result_all,
"total": result["total"],
"success_num": result["success_num"],
"fail_num": result["fail_num"],
"success_rate": result["success_rate"],
"fail_rate": result["fail_rate"],
"start_time": time["start_time"],
"end_time": time["end_time"],
"duration": time["duration"],
"test_sys": summary["test_sys"],
"test_modules": summary["test_modules"]
}
markdown_template = get_markdown_template()
markdown = common_util.replace_string(markdown_template, message_data)
msg = {
"title": "接口测试概况",
"text": markdown
}
sddm = SendDingDindMsg(web_hook, msg)
sddm.send_dingding_message(message_type="markdown")
# coding:utf-8
import json
import operator
import re
from Common.operation_log import Log
log = Log.get_logger(__name__)
def is_contain(str_one, str_two):
"""
判断一个字符串是否再另外一个字符串中
str_one:查找的字符串
str_two:被查找的字符串
"""
if isinstance(str_one, str):
str_one = str(str_one)
return operator.le(str_one, str_two)
def is_equal_dict(dict_one, dict_two):
"""判断两个字典是否相等"""
if isinstance(dict_one, str):
dict_one = json.loads(dict_one)
if isinstance(dict_two, str):
dict_two = json.loads(dict_two)
return operator.eq(dict_one, dict_two)
def test_result_verify(except_value, real_value, assert_type=None):
log.info("校验期望结果的参数:except_value:%s, real_value:%s, assert_type: %s" % (except_value, real_value, assert_type))
print("校验期望结果的参数:except_value:%s, real_value:%s, assert_type: %s" % (except_value, real_value, assert_type))
flag = False
try:
if assert_type == "equal" or assert_type is None:
flag = operator.eq(str(real_value), except_value)
elif assert_type.strip() == "contain":
flag = True if str(except_value) in str(real_value) else False
elif assert_type.strip() == "be_contain":
flag = True if str(real_value) in str(except_value) else False
elif assert_type.strip() == "not_contain":
flag = False if str(except_value) in str(real_value) else True
elif assert_type.strip() == "not_null":
flag = True if real_value else False
elif assert_type.strip() == "is_null":
flag = False if real_value else True
elif assert_type.strip() == "start_with":
flag = str(real_value).startswith(str(except_value))
elif assert_type.strip() == "end_with":
flag = str(real_value).endswith(str(except_value))
elif assert_type.strip() == "regular":
pattern = re.compile(str(except_value), re.M)
flag = True if pattern.findall(str(real_value)) else False
else:
flag = operator.eq(str(real_value), str(except_value))
except Exception as e:
print("断言异常:%s" % repr(e))
return flag
{"uuid": "22d20768-a40c-4e04-b6f7-85761b6bf6ca", "children": ["3ca52a36-b8e4-4664-b382-8cd30ccce597"], "befores": [{"name": "ji_yun_ying_app_login", "status": "passed", "start": 1611303213760, "stop": 1611303213760}], "start": 1611303213760, "stop": 1611303213761}
\ No newline at end of file
{"name": "test_search_class", "status": "passed", "start": 1611303213763, "stop": 1611303213764, "uuid": "385719dd-9269-459b-98bd-e4a0b8e43445", "historyId": "75e8bee1a6b62ee6697b6c80b080aeb6", "testCaseId": "eee66694770c43423daef356f20e1788", "fullName": "script.ji_yun_ying_app.test_order.TestOrder#test_search_class", "labels": [{"name": "story", "value": "极运营app查询班级"}, {"name": "feature", "value": "极运营app订单业务"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_order"}, {"name": "subSuite", "value": "TestOrder"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_order"}]}
\ No newline at end of file
{"name": "test_edit_clue2", "status": "passed", "start": 1611303213756, "stop": 1611303213757, "uuid": "43c784ad-accd-448f-b269-980a35ce51cb", "historyId": "dffe0ae69819874674ed19df57d90581", "testCaseId": "00413d8c3fab1c6a4db0eb9214d6f7a1", "fullName": "script.ji_yun_ying_app.test_crm.TestCrm#test_edit_clue2", "labels": [{"name": "feature", "value": "CRM线索"}, {"name": "story", "value": "编辑线索2"}, {"name": "tag", "value": "run(order=2)"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_crm"}, {"name": "subSuite", "value": "TestCrm"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_crm"}]}
\ No newline at end of file
{"name": "test_edit_clue1", "status": "passed", "start": 1611303213758, "stop": 1611303213758, "uuid": "abacb707-9a80-4e9a-9b21-42ca68d761c9", "historyId": "ceed495201cdab6b88d5fa9db53e829b", "testCaseId": "7119d3eb2d39fcef1bda61e730585e5b", "fullName": "script.ji_yun_ying_app.test_crm.TestCrm#test_edit_clue1", "labels": [{"name": "story", "value": "编辑线索1"}, {"name": "feature", "value": "CRM线索"}, {"name": "tag", "value": "run(order=3)"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_crm"}, {"name": "subSuite", "value": "TestCrm"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_crm"}]}
\ No newline at end of file
{"name": "test_new_clue", "status": "passed", "start": 1611303213760, "stop": 1611303213760, "uuid": "3ca52a36-b8e4-4664-b382-8cd30ccce597", "historyId": "f9a750aa47368abf7e12dddcdbcf88e9", "testCaseId": "cedd00314107b9274d69d24be89ab479", "fullName": "script.ji_yun_ying_app.test_crm.TestCrm#test_new_clue", "labels": [{"name": "feature", "value": "CRM线索"}, {"name": "story", "value": "新建线索"}, {"name": "tag", "value": "@pytest.mark.usefixtures('ji_yun_ying_app_login')"}, {"name": "tag", "value": "run(order=4)"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_crm"}, {"name": "subSuite", "value": "TestCrm"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_crm"}]}
\ No newline at end of file
{"uuid": "557529ca-f28d-4037-90ea-ff673717ae22", "children": ["edc83e40-a029-4fb1-9d36-1fbdbd0fcba1", "43c784ad-accd-448f-b269-980a35ce51cb", "abacb707-9a80-4e9a-9b21-42ca68d761c9", "3ca52a36-b8e4-4664-b382-8cd30ccce597", "320b6a9e-4b28-41ba-9125-64b0dd5bb019", "385719dd-9269-459b-98bd-e4a0b8e43445"], "befores": [{"name": "pytestconfig", "status": "passed", "start": 1611303213754, "stop": 1611303213754}], "start": 1611303213754, "stop": 1611303213764}
\ No newline at end of file
{"name": "test_search_student", "status": "passed", "start": 1611303213762, "stop": 1611303213762, "uuid": "320b6a9e-4b28-41ba-9125-64b0dd5bb019", "historyId": "64312dbca1571b40d2b0367b01d2dd04", "testCaseId": "43f385bb05f521acab96836e34ada383", "fullName": "script.ji_yun_ying_app.test_order.TestOrder#test_search_student", "labels": [{"name": "feature", "value": "极运营app订单业务"}, {"name": "story", "value": "极运营app选择学生"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_order"}, {"name": "subSuite", "value": "TestOrder"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_order"}]}
\ No newline at end of file
{"name": "test_edit_clue3", "status": "passed", "start": 1611303213755, "stop": 1611303213755, "uuid": "edc83e40-a029-4fb1-9d36-1fbdbd0fcba1", "historyId": "b7d0d6c74b714d12d52325c382abd02c", "testCaseId": "1de01759caafb017cef1c577c04e6260", "fullName": "script.ji_yun_ying_app.test_crm.TestCrm#test_edit_clue3", "labels": [{"name": "feature", "value": "CRM线索"}, {"name": "story", "value": "编辑线索3"}, {"name": "tag", "value": "run(order=1)"}, {"name": "parentSuite", "value": "script.ji_yun_ying_app"}, {"name": "suite", "value": "test_crm"}, {"name": "subSuite", "value": "TestCrm"}, {"name": "host", "value": "huangqiangdeMacBook-Pro.local"}, {"name": "thread", "value": "11988-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "script.ji_yun_ying_app.test_crm"}]}
\ No newline at end of file
{"uuid": "6bf62bbe-aa70-4ca4-acfa-ac224d631168", "children": ["edc83e40-a029-4fb1-9d36-1fbdbd0fcba1", "43c784ad-accd-448f-b269-980a35ce51cb", "abacb707-9a80-4e9a-9b21-42ca68d761c9", "3ca52a36-b8e4-4664-b382-8cd30ccce597", "320b6a9e-4b28-41ba-9125-64b0dd5bb019", "385719dd-9269-459b-98bd-e4a0b8e43445"], "befores": [{"name": "get_host", "status": "passed", "start": 1611303213754, "stop": 1611303213754}], "start": 1611303213754, "stop": 1611303213764}
\ No newline at end of file
import pytest
import os
if __name__ == '__main__':
run_config = [
"-s", "./script/ji_yun_ying_app", "--alluredir", "./report/xml", "--host=http://172.10.62.94:3000",
]
pytest.main(run_config)
# os模块运行allure命令,来生成html格式的报告(根据刚刚生成的配置信息)
# os.system("/Users/huangqiang/WorkPlace/allure-2.13.8/bin/allure generate ./report/xml -o ./report/html --clean")
host = "https://yf1.jkwljy.com/"
import pytest
from script import common_config
def pytest_addoption(parser):
# 注册一个命令行选项host
parser.addoption("--host", default="https://yf1.jkwljy.com/", dest="env", help="set test run env")
@pytest.fixture(scope='session', autouse=True)
def get_host(pytestconfig):
# 初始化测试环境变量
common_config.host = pytestconfig.getoption('--host')
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
import pytest
@allure.feature("登录极运营app")
@pytest.fixture()
def ji_yun_ying_app_login():
print("极运营app登录接口")
assert 1 == 1
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
import pytest
from script import common_config
@allure.feature("CRM线索")
class TestCrm:
@allure.story("新建线索")
@pytest.mark.usefixtures("ji_yun_ying_app_login")
@pytest.mark.run(order=4)
def test_new_clue(self):
print("新建线索")
assert 1 == 1
print(common_config.host)
@allure.story("编辑线索1")
@pytest.mark.run(order=3)
def test_edit_clue1(self):
print("编辑线索1")
assert 1 == 1
@allure.story("编辑线索2")
@pytest.mark.run(order=2)
def test_edit_clue2(self):
print("编辑线索2")
assert 1 == 1
@allure.story("编辑线索3")
@pytest.mark.run(order=1)
def test_edit_clue3(self):
print("编辑线索3")
assert 1 == 1
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
from script import common_config
@allure.feature("极运营app订单业务")
class TestOrder:
@allure.story("极运营app选择学生")
def test_search_student(self):
print("极运营app选择学生")
print(common_config.host)
@allure.story("极运营app查询班级")
def test_search_class(self):
pass
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
import pytest
# 1.conftest中fixture的scope参数为session,那么所有的测试文件执行前执行一次
# 2.conftest中fixture的scope参数为module,那么每一个测试文件执行前都会执行一次conftest文件中的fixture
# 3.conftest中fixture的scope参数为class,那么每一个测试文件中的测试类执行前都会执行一次conftest文件中的fixture
# 4.conftest中fixture的scope参数为function,那么所有文件的测试用例执行前都会执行一次conftest文件中的fixture
# @allure.feature("极运营登录")
@pytest.fixture()
@allure.story("极运营登录接口")
def ji_yun_ying_login():
url = data_config.host + "/service-user/auth/employee"
body_data = data_config.login_data[0]
res_json, res_header = RunMethod.run_main("POST", url, body_data=body_data, header=data_config.header)
print("登录极运营")
assert res_json.get("code", "-1") == 0
return "token"
host = "http://172.10.62.94:3000"
login_data = [
{"type": "employee",
"identityType": 1,
"ip": "0.0.0.0",
"account": "15360956010",
"password": "88888888",
"assistant": False
}
]
header = {
"Content-Type": "application/json;charset=UTF-8"
}
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
@allure.feature("班级")
class TestClass:
@allure.story("新建班级")
def test_new_class(self, ji_yun_ying_login):
print("新建班级", ji_yun_ying_login)
assert 1 == 1
@allure.story("编辑班级")
def test_edit_class(self):
print("编辑线索班级")
assert 1 == 1
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
@allure.feature("课程")
class TestCourse:
@allure.story("新建课程")
def test_new_course(self):
print("新建课程")
assert 1 == 1
@allure.story("编辑课程")
def test_edit_course(self):
print("编辑课程")
assert 1 == 1
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
@allure.feature("极运营PC订单业务")
class TestOrder:
@allure.story("极运营PC选择学生")
def test_search_student(self):
print("极运营PC查询学生接口")
assert 1 == 1
@allure.story("极运营PC查询班级")
def test_get_user_info(self):
print("极运营PC查询班级接口")
assert 1 == 1
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
import pytest
@allure.feature("登录家长pp")
@pytest.fixture(scope="session", autouse=True)
def login():
print("家长app登录接口")
return "---------"
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
@allure.feature("家长购课单")
class TestCourseSingle:
@allure.story("查询购课单班级")
def test_single_list(self, login):
pass
@allure.story("查询优惠信息")
def test_search_discount(self, login):
pass
from common.run_method import RunMethod
from script.ji_yun_ying_pc import data_config
import allure
@allure.feature("家长选课列表")
class TestClassList:
@allure.story("家长获取校区")
def test_school_area_list(self):
pass
@allure.story("家长班级列表接口")
def test_class_list(self):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment