3
3
# @Author : Hui
4
4
# @File : models.py
5
5
from config import db
6
- from config import config
6
+ from datetime import datetime
7
7
from passlib .apps import custom_app_context as pwd_context
8
- from itsdangerous import TimedJSONWebSignatureSerializer as Serializer ,SignatureExpired ,BadSignature
9
8
# 创建模型对象
10
9
11
10
class User (db .Model ):
12
11
__tablename__ = 'users'
13
- id = db .Column (db .Integer , primary_key = True )
14
- username = db .Column (db .String (32 ), index = True )
15
- password_hash = db .Column (db .String (128 ))
12
+ id = db .Column (db .Integer , primary_key = True ,comment = '主键,自增' )
13
+ account = db .Column (db .String (64 ), unique = True , index = True , comment = '账号' )
14
+ username = db .Column (db .String (32 ), comment = '姓名' )
15
+ password_hash = db .Column (db .String (128 ),comment = '密码' )
16
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now )
17
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
16
18
17
19
def hash_password (self , password ):
18
20
self .password_hash = pwd_context .encrypt (password )
@@ -21,6 +23,75 @@ def verify_password(self, password):
21
23
return pwd_context .verify (password , self .password_hash )
22
24
23
25
26
+ class Project (db .Model ):
27
+ __tablename__ = 'project'
28
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
29
+ user_id = db .Column (db .Integer (), nullable = True , comment = '所属的用户id' )
30
+ name = db .Column (db .String (64 ), nullable = True , unique = True , comment = '项目名称' )
31
+ host = db .Column (db .String (1024 ), nullable = True , comment = '测试环境' )
32
+ host_two = db .Column (db .String (1024 ), comment = '开发环境' )
33
+ host_three = db .Column (db .String (1024 ), comment = '线上环境' )
34
+ host_four = db .Column (db .String (1024 ), comment = '备用环境' )
35
+ environment_choice = db .Column (db .String (16 ), comment = '环境选择,first为测试,以此类推' )
36
+ principal = db .Column (db .String (16 ), nullable = True )
37
+ variables = db .Column (db .String (2048 ), comment = '项目的公共变量' )
38
+ headers = db .Column (db .String (1024 ), comment = '项目的公共头部信息' )
39
+ func_file = db .Column (db .String (64 ), nullable = True , unique = True , comment = '函数文件' )
40
+ modules = db .relationship ('Module' , order_by = 'Module.num.asc()' , lazy = 'dynamic' )
41
+ configs = db .relationship ('Config' , order_by = 'Config.num.asc()' , lazy = 'dynamic' )
42
+ case_sets = db .relationship ('CaseSet' , order_by = 'CaseSet.num.asc()' , lazy = 'dynamic' )
43
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now , comment = '创建时间' )
44
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
45
+
46
+
47
+ class Module (db .Model ):
48
+ __tablename__ = 'module'
49
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
50
+ name = db .Column (db .String (64 ), nullable = True , comment = '接口模块' )
51
+ num = db .Column (db .Integer (), nullable = True , comment = '模块序号' )
52
+ project_id = db .Column (db .Integer , db .ForeignKey ('project.id' ), comment = '所属的项目id' )
53
+ api_msg = db .relationship ('ApiMsg' , order_by = 'ApiMsg.num.asc()' , lazy = 'dynamic' )
54
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now , comment = '创建时间' )
55
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
56
+
57
+
58
+ class Config (db .Model ):
59
+ __tablename__ = 'config'
60
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
61
+ num = db .Column (db .Integer (), nullable = True , comment = '配置序号' )
62
+ name = db .Column (db .String (128 ), comment = '配置名称' )
63
+ variables = db .Column (db .String (21000 ), comment = '配置参数' )
64
+ func_address = db .Column (db .String (128 ), comment = '配置函数' )
65
+ project_id = db .Column (db .Integer , db .ForeignKey ('project.id' ), comment = '所属的项目id' )
66
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now , comment = '创建时间' )
67
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
68
+
69
+
70
+ class CaseSet (db .Model ):
71
+ __tablename__ = 'case_set'
72
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
73
+ num = db .Column (db .Integer (), nullable = True , comment = '用例集合序号' )
74
+ name = db .Column (db .String (256 ), nullable = True , comment = '用例集名称' )
75
+ project_id = db .Column (db .Integer , db .ForeignKey ('project.id' ), comment = '所属的项目id' )
76
+ cases = db .relationship ('Case' , order_by = 'Case.num.asc()' , lazy = 'dynamic' )
77
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now , comment = '创建时间' )
78
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
79
+
80
+
81
+ class Case (db .Model ):
82
+ __tablename__ = 'case'
83
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
84
+ num = db .Column (db .Integer (), nullable = True , comment = '用例序号' )
85
+ name = db .Column (db .String (128 ), nullable = True , comment = '用例名称' )
86
+ desc = db .Column (db .String (256 ), comment = '用例描述' )
87
+ func_address = db .Column (db .String (256 ), comment = '用例需要引用的函数' )
88
+ variable = db .Column (db .Text (), comment = '用例公共参数' )
89
+ times = db .Column (db .Integer (), nullable = True , comment = '执行次数' )
90
+ project_id = db .Column (db .Integer , db .ForeignKey ('project.id' ), comment = '所属的项目id' )
91
+ case_set_id = db .Column (db .Integer , db .ForeignKey ('case_set.id' ), comment = '所属的用例集id' )
92
+ environment = db .Column (db .Integer (), comment = '环境类型' )
93
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now , comment = '创建时间' )
94
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
24
95
25
96
26
97
# def __repr__(self):
@@ -40,6 +111,67 @@ class Test(db.Model):
40
111
expect2 = db .Column (db .String (120 ),nullable = False ,comment = '预期结果2' )
41
112
expect3 = db .Column (db .String (120 ),nullable = False ,comment = '预期结果3' )
42
113
114
+ class ApiMsg (db .Model ):
115
+ __tablename__ = 'api_msg'
116
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
117
+ num = db .Column (db .Integer (), nullable = True , comment = '接口序号' )
118
+ name = db .Column (db .String (128 ), nullable = True , comment = '接口名称' )
119
+ desc = db .Column (db .String (256 ), nullable = True , comment = '接口描述' )
120
+ variable_type = db .Column (db .String (32 ), nullable = True , comment = '参数类型选择' )
121
+ status_url = db .Column (db .String (32 ), nullable = True , comment = '基础url,序号对应项目的环境' )
122
+ up_func = db .Column (db .String (128 ), comment = '接口执行前的函数' )
123
+ down_func = db .Column (db .String (128 ), comment = '接口执行后的函数' )
124
+ method = db .Column (db .String (32 ), nullable = True , comment = '请求方式' )
125
+ variable = db .Column (db .Text (), comment = 'form-data形式的参数' )
126
+ json_variable = db .Column (db .Text (), comment = 'json形式的参数' )
127
+ param = db .Column (db .Text (), comment = 'url上面所带的参数' )
128
+ url = db .Column (db .String (256 ), nullable = True , comment = '接口地址' )
129
+ skip = db .Column (db .String (256 ), comment = '跳过判断' )
130
+ extract = db .Column (db .String (2048 ), comment = '提取信息' )
131
+ validate = db .Column (db .String (2048 ), comment = '断言信息' )
132
+ header = db .Column (db .String (2048 ), comment = '头部信息' )
133
+ module_id = db .Column (db .Integer , db .ForeignKey ('module.id' ), comment = '所属的接口模块id' )
134
+ project_id = db .Column (db .Integer , nullable = True , comment = '所属的项目id' )
135
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now )
136
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
137
+
138
+
139
+ class CaseData (db .Model ):
140
+ __tablename__ = 'case_data'
141
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
142
+ num = db .Column (db .Integer (), nullable = True , comment = '步骤序号,执行顺序按序号来' )
143
+ status = db .Column (db .String (16 ), comment = '状态,true表示执行,false表示不执行' )
144
+ name = db .Column (db .String (128 ), comment = '步骤名称' )
145
+ up_func = db .Column (db .String (256 ), comment = '步骤执行前的函数' )
146
+ down_func = db .Column (db .String (256 ), comment = '步骤执行后的函数' )
147
+ skip = db .Column (db .String (64 ), comment = '跳过判断函数' )
148
+ time = db .Column (db .Integer (), default = 1 , comment = '执行次数' )
149
+ param = db .Column (db .Text (), default = u'[]' )
150
+ status_param = db .Column (db .String (64 ), default = u'[true, true]' )
151
+ variable = db .Column (db .Text ())
152
+ json_variable = db .Column (db .Text ())
153
+ status_variables = db .Column (db .String (64 ))
154
+ extract = db .Column (db .String (2048 ))
155
+ status_extract = db .Column (db .String (64 ))
156
+ validate = db .Column (db .String (2048 ))
157
+ status_validate = db .Column (db .String (64 ))
158
+ header = db .Column (db .String (2048 ))
159
+ status_header = db .Column (db .String (64 ))
160
+ case_id = db .Column (db .Integer , db .ForeignKey ('case.id' ))
161
+ api_msg_id = db .Column (db .Integer , db .ForeignKey ('api_msg.id' ))
162
+ created_time = db .Column (db .DateTime , index = True , default = datetime .now )
163
+ update_time = db .Column (db .DateTime , index = True , default = datetime .now , onupdate = datetime .now )
164
+
165
+
166
+ class Report (db .Model ):
167
+ __tablename__ = 'report'
168
+ id = db .Column (db .Integer (), primary_key = True , comment = '主键,自增' )
169
+ case_names = db .Column (db .String (128 ), nullable = True , comment = '用例的名称集合' )
170
+ read_status = db .Column (db .String (16 ), nullable = True , comment = '阅读状态' )
171
+ performer = db .Column (db .String (16 ), nullable = True , comment = '执行者' )
172
+ project_id = db .Column (db .String (16 ), nullable = True )
173
+ create_time = db .Column (db .DateTime (), index = True , default = datetime .now )
174
+
43
175
44
176
#
45
177
# def __repr__(self):
0 commit comments