-
Notifications
You must be signed in to change notification settings - Fork 50
/
test_api.py
53 lines (39 loc) · 1.02 KB
/
test_api.py
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
# -*- coding: utf-8 -*-
# @Time : 2022/7/19 11:15
# @Author : ShaHeTop-Almighty-ares
# @Email : [email protected]
# @File : test_api.py
# @Software: PyCharm
from all_reference import *
from tasks.celery_tasks.task03 import test_orm
class TestMethodView(MethodView):
"""
测试 view demo
"""
def get(self):
"""测试内部异常"""
print(1 / 0) #
return
def post(self):
"""测试自定义异常"""
return ab_code(666)
class TestRestful(Resource):
"""
测试 restful demo
"""
def get(self):
"""测试内部异常"""
print(1 / 0)
return
def post(self):
"""测试自定义异常"""
return ab_code_2(666)
class TestCeleryTask(MethodView):
"""
测试异步任务
"""
def get(self):
"""测试异步任务"""
results = test_orm.delay()
print(results)
return api_result(code=200, message='操作成功,请前往日志查看执行结果', data=[str(results)])