mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
update: redis配置适配密码格式
create:加入自动化测试管理模块
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import JSON, Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class APICaseModel(ModelBase):
|
||||
"""
|
||||
自动化-接口用例表
|
||||
"""
|
||||
__tablename__ = "auto_api_case"
|
||||
__table_args__ = ({'comment': '自动化-接口用例表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="测试用例名称")
|
||||
|
||||
url = Column(String, nullable=False, comment="接口地址")
|
||||
method = Column(String, nullable=False, comment="请求方法")
|
||||
headers = Column(JSON, comment="请求头")
|
||||
data_type = Column(String, nullable=False, comment="请求参数类型(params/data/json/file)")
|
||||
data = Column(JSON, comment="请求参数")
|
||||
|
||||
expected_status_code = Column(Integer, comment="预期状态码")
|
||||
expected_msg = Column(String, comment="预期消息")
|
||||
expected_response = Column(JSON, comment="预期响应")
|
||||
assertions_status_code = Column(String, comment="状态码断言规则(=, !=, >, <, >=, <=, in, not in)")
|
||||
assertions_msg = Column(String, comment="消息断言规则(=, !=, >, <, >=, <=, in, not in)")
|
||||
assertions_response = Column(String, comment="响应断言规则(=, !=, >, <, >=, <=, in, not in)")
|
||||
|
||||
environment_id = Column(Integer, ForeignKey("auto_environments.id"), comment="所属环境ID")
|
||||
global_data_id = Column(Integer, ForeignKey("auto_global_data.id"), comment="关联全局数据ID")
|
||||
module_id = Column(Integer, ForeignKey("auto_modules.id"), comment="所属模块ID")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class EnvironmentModel(ModelBase):
|
||||
"""
|
||||
自动化-环境表
|
||||
"""
|
||||
__tablename__ = "auto_environments"
|
||||
__table_args__ = ({'comment': '自动化-环境表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="环境名称")
|
||||
base_url = Column(String, nullable=False, comment="基础URL")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import JSON, Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class GlobalDataModel(ModelBase):
|
||||
"""
|
||||
配置表 - 用于存储组织架构中的配置信息
|
||||
"""
|
||||
__tablename__ = "auto_global_data"
|
||||
__table_args__ = ({'comment': '自动化-全局参数表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="参数名称")
|
||||
value = Column(String, nullable=False, comment="参数值")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class ModuleModel(ModelBase):
|
||||
"""
|
||||
自动化-环境表
|
||||
"""
|
||||
__tablename__ = "auto_modules"
|
||||
__table_args__ = ({'comment': '自动化-模块表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="模块名称")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import JSON, Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class NotificationConfigModel(ModelBase):
|
||||
"""
|
||||
自动化-环境表
|
||||
"""
|
||||
__tablename__ = "auto_notification_config"
|
||||
__table_args__ = ({'comment': '自动化-通知配置表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="通知类型(邮件、钉钉、Slack等)")
|
||||
config = Column(JSON, nullable=False, comment="通知配置")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class ProjectModel(ModelBase):
|
||||
"""
|
||||
自动化-项目表
|
||||
"""
|
||||
__tablename__ = "auto_projects"
|
||||
__table_args__ = ({'comment': '自动化-项目表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="项目名称")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import JSON, Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class ReportModel(ModelBase):
|
||||
"""
|
||||
自动化-环境表
|
||||
"""
|
||||
__tablename__ = "auto_report"
|
||||
__table_args__ = ({'comment': '自动化-测试报告表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String(40), nullable=False, default="名称", comment="名称")
|
||||
task_id = Column(Integer, nullable=False, comment="关联的任务ID")
|
||||
summary = Column(JSON, comment="报告摘要")
|
||||
details = Column(JSON, comment="详细报告")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class SuiteModel(ModelBase):
|
||||
"""
|
||||
自动化-步骤表
|
||||
"""
|
||||
__tablename__ = "auto_suite"
|
||||
__table_args__ = ({'comment': '自动化-测试套件表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, unique=True, comment='主键ID')
|
||||
|
||||
name = Column(String, nullable=False, comment="套件名称")
|
||||
project_id = Column(Integer, ForeignKey("auto_projects.id"), comment="所属项目ID")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import JSON, Column, String, Integer, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base_model import ModelBase
|
||||
|
||||
|
||||
class TaskModel(ModelBase):
|
||||
"""
|
||||
自动化-环境表
|
||||
"""
|
||||
__tablename__ = "auto_tasks"
|
||||
__table_args__ = ({'comment': '自动化-执行记录表'})
|
||||
|
||||
# 基础字段
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True, unique=True, comment='主键ID')
|
||||
|
||||
test_case_id = Column(Integer, nullable=False, comment="关联的测试用例ID")
|
||||
status = Column(String, nullable=False, comment="执行状态")
|
||||
logs = Column(JSON, comment="执行日志")
|
||||
actual_response = Column(JSON, comment="实际响应(仅API测试)")
|
||||
|
||||
# 审计字段
|
||||
description = Column(Text, nullable=True, comment="备注说明")
|
||||
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
creator_id = Column(
|
||||
Integer,
|
||||
ForeignKey("system_user.id", ondelete="SET NULL", onupdate="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="创建人ID"
|
||||
)
|
||||
creator = relationship(
|
||||
"UserModel",
|
||||
foreign_keys=creator_id,
|
||||
lazy="joined",
|
||||
post_update=True,
|
||||
uselist=False
|
||||
)
|
||||
Reference in New Issue
Block a user