1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
| # -*- coding: utf-8 -*-
| """
| @File : urls.py
| @Time : 2023/1/14 11:23
| @Author : geekbing
| @LastEditTime : -
| @LastEditors : -
| @Description : -
| """
|
| from django.urls import path
| from lunarlink.views import (
| api,
| ci,
| config,
| debugtalk,
| project,
| report,
| run,
| schedule,
| suite,
| yapi,
| variables, # 确保variables已经导入
| )
|
|
| urlpatterns = [
| # 访问统计相关接口
| path(
| "visit",
| project.VisitView.as_view({"get": "list"}),
| ),
| # 项目相关接口
| path(
| "project",
| project.ProjectView.as_view(
| {
| "get": "list",
| "post": "add",
| "patch": "update",
| "delete": "delete",
| }
| ),
| ),
| path("project/<int:pk>", project.ProjectView.as_view({"get": "single"})),
| path("project/yapi/<int:pk>", project.ProjectView.as_view({"get": "yapi_info"})),
| path("project/groups", project.ProjectView.as_view({"get": "group_list"})),
| path("dashboard", project.DashBoardView.as_view()),
| # 二叉树接口
| path("tree/<int:pk>", project.TreeView.as_view()),
| # 导入yapi
| path("yapi/<int:pk>", yapi.YAPIView.as_view()),
| # api模板
| path(
| "api",
| api.APITemplateView.as_view(
| {
| "post": "add",
| "get": "list",
| "delete": "bulk_destroy",
| }
| ),
| ),
| path(
| "api/<int:pk>",
| api.APITemplateView.as_view(
| {
| "delete": "destroy",
| "patch": "update",
| "post": "copy",
| "get": "single",
| }
| ),
| ),
| path(
| "api/move_api",
| api.APITemplateView.as_view({"patch": "move"}), # api修改relation所属目录
| ),
| path(
| "api/tag",
| api.APITemplateView.as_view({"patch": "add_tag"}), # api修改状态
| ),
| path(
| "api/sync/<int:pk>",
| api.APITemplateView.as_view({"patch": "sync_case"}), # api同步测试用例
| ),
| # 测试用例
| path(
| "test",
| suite.TestCaseView.as_view(
| {
| "get": "get",
| "post": "post",
| "delete": "bulk_destroy",
| }
| ),
| ),
| path(
| "test/<int:pk>",
| suite.TestCaseView.as_view(
| {
| # 如果请求方法和处理方法同名时可以省略
| "post": "copy",
| "delete": "destroy",
| "put": "put",
| "patch": "patch",
| }
| ),
| ),
| path(
| "test/move_case",
| suite.TestCaseView.as_view({"patch": "move"}), # case修改relation
| ),
| path(
| "test/tag",
| suite.TestCaseView.as_view({"patch": "update_tag"}),
| ),
| path("teststep/<int:pk>", suite.CaseStepView.as_view()),
| # 用例录制
| path("record/start", suite.RecordStartView.as_view(), name="record_start"),
| path("record/stop", suite.RecordStopView.as_view(), name="record_stop"),
| path("record/status", suite.RecordStatusView.as_view(), name="record_status"),
| path("record/remove", suite.RecordRemoveView.as_view(), name="record_remove"),
| path("record_case", suite.GenerateCaseView.as_view(), name="generate_case"),
| # run api 运行API
| path("run_api_pk/<int:pk>", run.run_api_pk),
| path("run_api", run.run_api),
| # run testsuite 运行测试用例集
| path("run_testsuite", run.run_testsuite),
| path("run_testsuite_pk/<int:pk>", run.run_testsuite_pk),
| path("run_test", run.run_test),
| path("run_suite_tree", run.run_suite_tree),
| path("run_multi_tests", run.run_multi_tests),
| # config-配置管理
| path(
| "config",
| config.ConfigView.as_view(
| {
| "post": "add",
| "get": "list",
| "delete": "bulk_destroy",
| }
| ),
| ),
| path(
| "config/<int:pk>",
| config.ConfigView.as_view(
| {
| "patch": "update",
| "post": "copy",
| "delete": "destroy",
| "get": "all",
| }
| ),
| ),
| # 全局变量
| path(
| "variables",
| variables.VariablesView.as_view(
| {
| "get": "list",
| "post": "add",
| "delete": "bulk_destroy",
| }
| ),
| ),
| path(
| "variables/<int:pk>",
| variables.VariablesView.as_view(
| {
| "patch": "update",
| "delete": "destroy",
| }
| ),
| ),
| # debugtalk.py相关接口
| path("debugtalk/<int:pk>", debugtalk.DebugTalkView.as_view({"get": "debugtalk"})),
| path(
| "debugtalk",
| debugtalk.DebugTalkView.as_view(
| {
| "patch": "update",
| "post": "run",
| }
| ),
| ),
| # 历史报告
| path(
| "reports",
| report.ReportView.as_view(
| {
| "get": "list",
| "delete": "bulk_destroy",
| }
| ),
| ),
| path(
| "reports/<int:pk>",
| report.ReportView.as_view(
| {
| "delete": "destroy",
| "get": "look",
| }
| ),
| ),
| # 定时任务相关接口
| path(
| "schedule",
| schedule.ScheduleView.as_view(
| {
| "get": "list",
| "post": "add",
| }
| ),
| ),
| path(
| "schedule/<int:pk>",
| schedule.ScheduleView.as_view(
| {
| "get": "run",
| "put": "update",
| "patch": "patch",
| "delete": "delete",
| "post": "copy",
| }
| ),
| ),
| # gitlab-ci, 当前暂未用到
| path(
| "gitlab-ci/",
| ci.CIView.as_view(
| {
| "post": "run_ci_tests",
| "get": "get_ci_report_url",
| }
| ),
| ),
| ]
|
|