1 Star 0 Fork 0

disenQF/xd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
api_test.py 3.86 KB
一键复制 编辑 原始数据 按行查看 历史
张思聪 提交于 2021-06-22 15:28 . 路径优化
from unittest.case import TestCase
import requests
class UserTest(TestCase):
base_url = 'http://10.36.174.17:8888'
def full_url(self, path):
return self.base_url + path
def test_login(self):
url = self.full_url('/user/login/')
data = {
'username':'maosheng',
'password':'742664'
}
resp = requests.post(url,json=data)
print(resp.text)
def test_code(self):
url = self.full_url('/user/code/?phone=17782788743')
resp = requests.get(url)
print(resp.json())
def test_regist(self):
url = self.full_url('/user/regist/')
json_data = {
'username': 'maosheng',
'password1': '742664',
'password2': '742664',
'phone': '17782788743',
'user_code': 'Qb8e'
}
resp = requests.post(url, json=json_data)
print(resp.text)
def test_head(self):
token = '8312bd0f785018fd1ec1f4528cfb334735f18334'
url = self.full_url('/user/upload/')
headers={
'Authorization': 'Token '+token
}
with open(r'F:\HTML-5\xiu-ddms\src\assets\head.jpg', 'rb') as f:
resp = requests.post(url, headers=headers, files={
'head': ('nv.jpg', f, 'image/jpeg')
})
print(resp.text)
def test_address(self):
url = self.full_url('/user/address/')
token = '518c997090d95439c4f5fb2970532a395046f55c'
headers = {
'Authorization': 'Token ' + token
}
resp = requests.get(url,headers=headers)
print(resp.text)
def test_add_address(self):
url = self.full_url('/user/address/')
token = '518c997090d95439c4f5fb2970532a395046f55c'
headers = {
'Authorization': 'Token ' + token
}
data = {
'user_name':'石头人',
'user_phone':'15965982459',
'user_add':'西安市雁塔区会展中心',
'is_default':'0'
}
resp = requests.post(url,headers=headers,json=data)
print(resp.text)
def test_show_list(self):
url = self.full_url('/show/musician/3')
resp = requests.get(url)
print(resp.text)
def test_indent(self):
url = self.full_url('/indent/')
token = '998d32b519aac231dfa591beff62f0d8a5fa5e37'
headers = {
'Authorization': 'Token ' + token
}
resp = requests.get(url,headers=headers)
print(resp.text)
def test_del_collect(self):
url = self.full_url('/indent/del_collect/')
token = '7f52de8e4ab518a4f95adcfc891ad445a9a7dd01'
headers = {
'Authorization': 'Token ' + token
}
resp = requests.post(url,headers=headers)
print(resp.text)
def test_add_collect(self):
url = self.full_url('/indent/collect/')
token = '7f52de8e4ab518a4f95adcfc891ad445a9a7dd01'
headers = {
'Authorization': 'Token ' + token
}
json_data = {
"show":'6',
}
resp = requests.post(url,headers=headers,json=json_data)
print(resp.text)
def test_add_indent(self):
url = self.full_url('/indent/')
token = '7f52de8e4ab518a4f95adcfc891ad445a9a7dd01'
headers = {
'Authorization': 'Token ' + token
}
json_data = {
'user_add':'2',
'show':'8',
'indent_date':'2021年6月4日9:52',
'indent_status':'0'
}
resp = requests.post(url,headers=headers,json=json_data)
print(resp.text)
def test_near(self):
url = self.full_url('/show/near/')
# {'lng': 108.876251, 'lat': 34.218136}
params = {
'lat': 34.218136,
'lng': 108.876251,
'dis': 20
}
resp = requests.get(url, params)
print(resp.text)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/disenQF/xdv2.git
[email protected]:disenQF/xdv2.git
disenQF
xdv2
xd
master

搜索帮助