霍格沃兹测试开发 ceshiren.com
class BuildEntity(db.Model):
# 表名
__tablename__ = "build"
# 用例ID 用例的唯 一标识
id = db.Column(Integer, primary_key=True)
# 用例的标题 或者文件名,限定 80个字符 ,不为空,并且唯一
plan_id = db.Column(Integer)
report = db.Column(String(80))
create_time = Column(DateTime, nullable=True, default=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
def as_dict(self):
return {"plan_id": self.plan_id, "report": self.report, "create_time": str(self.create_time)}
class PlanEntity(db.Model):
# 表名
__tablename__ = "plan"
# 用例ID 用例的唯 一标识
id = db.Column(Integer, primary_key=True)
# 用例的标题 或者文件名,限定 80个字符 ,不为空,并且唯一
name = db.Column(String(80), nullable=False, unique=True)
testcases = relationship("TestCaseEntity",
secondary=testcase_plan_rel,
backref="plans")
def as_dict(self):
return {"id": self.id, "name": self.name,
"testcase_info": " ".join([testcase.case_title for testcase in self.testcases]) }
# 中间表
testcase_plan_rel = db.Table(
'testcase_plan_rel',
Column('testcase_id', Integer,
ForeignKey('testcase.id'),
primary_key=True),
Column('plan_id', Integer,
ForeignKey('plan.id'),
primary_key=True)
)
# 测试计划表
class PlanEntity(db.Model):
# 表名
__tablename__ = "plan"
# 用例ID 用例的唯 一标识
id = db.Column(Integer, primary_key=True)
# 用例的标题 或者文件名,限定 80个字符 ,不为空,并且唯一
name = db.Column(String(80), nullable=False, unique=True)
testcases = relationship("TestCaseEntity",
secondary=testcase_plan_rel,
backref="plans")
def as_dict(self):
return {"id": self.id, "name": self.name,
"testcase_info": " ".join([testcase.case_title for testcase in self.testcases]) }
# 用例表
class TestCaseEntity(db.Model):
# 表名
__tablename__ = "testcase"
# 用例ID 用例的唯 一标识
id = db.Column(Integer, primary_key=True)
# 用例的标题 或者文件名,限定 80个字符 ,不为空,并且唯一
case_title = db.Column(String(80), nullable=False, unique=True)
# 备注
remark = db.Column(String(120))
# 用例的创建时间
# created_at = ""
def as_dict(self):
return {"id": self.id, "case_title": self.case_title, "remark": self.remark}
class BuildEntity(db.Model):
# 表名
__tablename__ = "build"
# 用例ID 用例的唯 一标识
id = db.Column(Integer, primary_key=True)
plan_id = Column(Integer)
report = Column(String(120))
create_time = Column(DateTime, nullable=True,
default= datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
# created_at = db.Column(db.DateTime, default=datetime.datetime.now())
# 用例的创建时间
# created_at = ""
def as_dict(self):
return {"plan_id": self.plan_id, "report": self.report,
"create_time": str(self.create_time)}
跨域请求:同源判断
URL | 结果 | 原因 |
---|---|---|
http://store.company.com/dir2/other.html |
– | – |
http://store.company.com/dir/inner/another.html |
– | – |
https://store.company.com/secure.html |
– | – |
http://store.company.com:81/dir/etc.html |
– | – |
http://news.company.com/dir/other.html |
– | – |
URL | 结果 | 原因 |
---|---|---|
http://store.company.com/dir2/other.html |
同源 | 只有路径不同 |
http://store.company.com/dir/inner/another.html |
同源 | 只有路径不同 |
https://store.company.com/secure.html |
失败 | 协议不同 |
http://store.company.com:81/dir/etc.html |
失败 | 端口不同 ( http:// 默认端口是80) |
http://news.company.com/dir/other.html |
失败 | 主机不同 |
pip install -U flask-cors
from flask_cors import CORS
# 实例化一个flask服务
app = Flask(__name__)
# 解决跨域
CORS(app, supports_credentials=True)