代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。