Commit 035f4203 authored by Wallen姚文辉's avatar Wallen姚文辉

修复bug

parent 1ecd1c2b
File added
from flask import Blueprint, request, jsonify,session from flask import Blueprint, request, jsonify,session
from manager.serverCenter import server,emailserver from manager.serverCenter import server
from model.Model import User,Emails from model.Model import User,Emails
import base64 import base64
import requests import requests
...@@ -22,14 +22,6 @@ def getheader(id_): ...@@ -22,14 +22,6 @@ def getheader(id_):
} }
return headers return headers
# def sendEmail(to,subject,contents=None,attachments=None):
# '''
# to 发送目标,数组时为多人
# subject 主题
# contents 内容
# attachments 附件,数组时为多个
# '''
# emailserver.server.send(to=to,subject=subject,contents=contents,attachments=attachments)
@tool.route('/testport/sendport', methods=["POST"]) @tool.route('/testport/sendport', methods=["POST"])
def sendport(): def sendport():
...@@ -38,8 +30,6 @@ def sendport(): ...@@ -38,8 +30,6 @@ def sendport():
user = 'wallen.ywh@galaxyoversea.com' user = 'wallen.ywh@galaxyoversea.com'
password = 'Ywh940509' password = 'Ywh940509'
yag = yagmail.SMTP( user=user, password=password, host='smtp.exmail.qq.com',port=465) yag = yagmail.SMTP( user=user, password=password, host='smtp.exmail.qq.com',port=465)
print(emailserver.server.__dict__)
# emailserver.server.send(data["to"],data.get("subject"),data.get("contents"))
yag.send(data["to"],data.get("subject"),data.get("contents")) yag.send(data["to"],data.get("subject"),data.get("contents"))
return jsonify({"code": 200, "message": "请求成功"}),200 return jsonify({"code": 200, "message": "请求成功"}),200
...@@ -110,8 +100,12 @@ def reportinfo(): ...@@ -110,8 +100,12 @@ def reportinfo():
for i in story: for i in story:
i["case"]=[] i["case"]=[]
i["childrenTask"]=[i.get("key")] i["childrenTask"]=[i.get("key")]
chan=i["extraFields"][0]["html"] chan=''
if chan not in peoples["chan"]: for m in i["extraFields"]:
if m.get("id")=="reporter":
chan=m.get("html")
break
if chan and chan not in peoples["chan"]:
peoples["chan"].append(chan) peoples["chan"].append(chan)
i["peoples"]=[chan] i["peoples"]=[chan]
info=requests.request("get",jiraAddress+"/rest/greenhopper/1.0/xboard/issue/details.json?rapidViewId="+str(id_)+"&issueIdOrKey="+i["key"]+"&loadSubtasks=true",headers=headers).json() info=requests.request("get",jiraAddress+"/rest/greenhopper/1.0/xboard/issue/details.json?rapidViewId="+str(id_)+"&issueIdOrKey="+i["key"]+"&loadSubtasks=true",headers=headers).json()
...@@ -125,12 +119,12 @@ def reportinfo(): ...@@ -125,12 +119,12 @@ def reportinfo():
i["peoples"].append(k) i["peoples"].append(k)
if (k and ( k in peoples["test"] or k in peoples["qian"] or k in peoples["hou"])) or not k: if (k and ( k in peoples["test"] or k in peoples["qian"] or k in peoples["hou"])) or not k:
continue continue
elif ("测试" in m.get("summary") or "用例" in m.get("summary")): elif "【前端】" in m.get("summary"):
peoples["test"].append(k)
elif "前端" in m.get("summary"):
peoples["qian"].append(k) peoples["qian"].append(k)
elif "后端" in m.get("summary"): elif "【后端】" in m.get("summary"):
peoples["hou"].append(k) peoples["hou"].append(k)
elif ("测试" in m.get("summary") or "用例" in m.get("summary")):
peoples["test"].append(k)
i["childrenTask"].append(m.get("key")) i["childrenTask"].append(m.get("key"))
elif j.get("tabId")=="THIRD_PARTY_TAB": elif j.get("tabId")=="THIRD_PARTY_TAB":
for each in j.get("sections"): for each in j.get("sections"):
......
from flask import Flask, request, jsonify, session, current_app from flask import Flask
import os import os
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from datetime import timedelta from datetime import timedelta
from datetime import datetime, date
from manager.tools import get_config from manager.tools import get_config
import yagmail
config=get_config() config=get_config()
mysqlConf=config["mysql"] mysqlConf=config["mysql"]
eamilConf=config["email"]
# redisConf=config["redis"]
# emailConf=config["email"]
# class CustomJSONEncoder(JSONEncoder):
# def default(self, obj):
# if isinstance(obj, datetime):
# return obj.strftime('%Y-%m-%d %H:%M:%S')
# elif isinstance(obj, date):
# return obj.strftime('%Y-%m-%d')
# else:
# return JSONEncoder.default(self, obj)
class server(): class server():
app = Flask(__name__, template_folder='auto_test/html', static_folder='') app = Flask(__name__, template_folder='auto_test/html', static_folder='')
app.config['SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{mysqlConf['user']}:{mysqlConf['password']}@{mysqlConf['host']}:{mysqlConf['port']}/{mysqlConf['db']}?charset=utf8mb4" app.config['SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{mysqlConf['user']}:{mysqlConf['password']}@{mysqlConf['host']}:{mysqlConf['port']}/{mysqlConf['db']}?charset=utf8mb4"
...@@ -30,19 +15,10 @@ class server(): ...@@ -30,19 +15,10 @@ class server():
app.config['SECRET_KEY'] = os.urandom(24) app.config['SECRET_KEY'] = os.urandom(24)
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
app.secret_key = "test" app.secret_key = "test"
# app.json_encoder = CustomJSONEncoder
db = SQLAlchemy(app) db = SQLAlchemy(app)
class emailserver():
server=yagmail.SMTP(user=eamilConf["user"], password=eamilConf["password"], host=eamilConf["host"],port=eamilConf["port"])
# def send(self,to,subject,contents=None,attachments=None):
# '''
# to 发送目标,数组时为多人
# contents 内容
# attachments 附件,数组时为多个
# '''
# emailserver.server.send()
This diff is collapsed.
import base64
import requests
import pandas as pd
import xmindparser
from copy import deepcopy
xmindparser.config = {
'showTopicId': True, # 是否展示主题ID
'hideEmptyValue': True # 是否隐藏空值
}
def relational_case(project):
jiraAddress,user,password="http://jira.galaxy-immi.com","wallen.ywh","ywh940509"
headers={
"Authorization":"Basic "+base64.b64encode((user+":"+password).encode('utf-8')).decode(),
"accept":"application/json,text/javascript,*/*;q=0.01"
}
id_=requests.request("get",jiraAddress+"/rest/agile/1.0/board?projectKeyOrId="+project,headers=headers).json().get("values")[0].get("id")
result=requests.request("get",jiraAddress+"/rest/greenhopper/1.0/xboard/plan/backlog/data.json?rapidViewId="+str(id_)+"&selectedProjectKey="+project,headers=headers).json()
all=result.get("issues")
type_={}
for k,v in result["entityData"]["types"].items():
type_[str(k)]=v["typeName"]
storyids={}
[storyids.update({i.get("key"):[]}) for i in list(filter(lambda x:type_[x["typeId"]]=="Story",all))]
for item in list(filter(lambda x:type_[x["typeId"]]=="测试用例",all)):
for each in storyids.keys():
each in item.get("summary") and storyids[each].append(item.get("key"))
for k,v in storyids.items():
print(k,v)
res=requests.request("post",jiraAddress+"/rest/synapse/latest/requirementTestCase/addTestCase",headers=headers,json={"currentReqkey":k,"testCaseKeys":v,"history":"yes"})
print(res.status_code)
print(res.url)
print(res.headers)
# print(res.)
def makecase(filePath):
content = xmindparser.xmind_to_dict(filePath)
case_list=[]
# print(content)
def a(info,new,type):
for each in info:
oldinfo=deepcopy(new)
newtype=type
if not ((each["title"])=="Map" or (each["title"])=="测试用例"):
if type=="name":
string=each.get("title")
if "tc:" in each.get("title") or "tc:" in each.get("title") or "tc:" in each.get("title"):
string=each.get("title").replace("tc:","").replace("tc:","").replace("tc:","")
newtype="step"
if oldinfo.get("name"):
oldinfo["name"]=oldinfo.get("name")+"->"+string
else:
oldinfo["name"]=string
elif type=="step":
newtype="expect"
oldinfo["step"]=each.get("title")
else:
oldinfo["expect"]=each.get("title")
if each.get("topic") or each.get("topics"):
(each.get("topic") and a([each.get("topic")],oldinfo,newtype))
(each.get("topics") and a(each.get("topics"),oldinfo,newtype))
else:
case_list.append(oldinfo)
a(content,{},"name")
# for each in case_list:
# print(each)
name=list(map(lambda x:x.get("name"),case_list))
step=list(map(lambda x:x.get("step"),case_list))
expect=list(map(lambda x:x.get("expect"),case_list))
dataframe = pd.DataFrame({"用例名":name,"用例步骤":step,"预期结果":expect})
dataframe.to_csv("test.csv",index=False,sep=',')
# makecase("/home/yaowenhui/galaxTestCenter/1.07.xmind")
relational_case("STARCOM")
\ No newline at end of file
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