Commit 536bb60b by zhaihuitao

update

parent c0b220c9
...@@ -5,12 +5,19 @@ ...@@ -5,12 +5,19 @@
# @File : config.py # @File : config.py
# @desc : # @desc :
""" """
import requests
import pytest
import param
Headers = {'Authorization': 'Bearer 3ba9c1c1-b398-472e-8ae4-b621ba52e283', # Headers = {'Authorization': 'Bearer 3ba9c1c1-b398-472e-8ae4-b621ba52e283',
'Content-Type': 'application/json;charset=UTF-8'} # 'Content-Type': 'application/json;charset=UTF-8'}
url_test = "http://117.50.4.194" url_test = "http://117.50.4.194"
url_prod = "http://gatling.reyun.com" url_prod = "http://gatling.reyun.com"
token_url = "http://gatling.reyun.com/api-u/oauth/user/token"
p2v = "/api-f/batchIm2Video/asyncBatchImg2V" p2v = "/api-f/batchIm2Video/asyncBatchImg2V"
v2v = "/api-f/video2video/generatedAsync/false" v2v = "/api-f/video2video/generatedAsync/false"
t2v = "/api-f/text2video/asyncGenerated" t2v = "/api-f/text2video/asyncGenerated"
...@@ -11,6 +11,15 @@ import json ...@@ -11,6 +11,15 @@ import json
title_id = json.load(open('title_id.json', 'r+'))['title_id'] + 1 title_id = json.load(open('title_id.json', 'r+'))['title_id'] + 1
json.dump({"title_id": title_id}, open('title_id.json', 'w+'), sort_keys=True, indent=4) json.dump({"title_id": title_id}, open('title_id.json', 'w+'), sort_keys=True, indent=4)
token_data = json.dumps({
"username": "2@qq.com",
"password": "reyun.123",
"clientId": "system",
"clientSecret": "system",
"scope": "app",
"grantType": "password"
})
p2v = json.dumps({ p2v = json.dumps({
"sizeId": 5, "sizeId": 5,
"title": title_id, "title": title_id,
......
...@@ -13,18 +13,31 @@ import param ...@@ -13,18 +13,31 @@ import param
import config import config
def getToken():
r = requests.post(url=config.token_url, data=param.token_data, headers={'Content-Type': 'application/json;charset=UTF-8'})
print(r.json())
t = r.json()["data"]["access_token"]
return t
class TestGatlingAPI: class TestGatlingAPI:
token = "Bearer" + " " + getToken()
headers = {
"authorization": token,
'Content-Type': 'application/json;charset=UTF-8'
}
def test_p2v(self): def test_p2v(self):
r = requests.post(url=config.url_prod + config.p2v, data=param.p2v, headers=config.Headers) r = requests.post(url=config.url_prod + config.p2v, data=param.p2v, headers=TestGatlingAPI.headers)
print(r.text) print(r.text)
assert r.status_code == 200 assert r.status_code == 200
def test_v2v(self): def test_v2v(self):
r = requests.post(url=config.url_prod + config.v2v, data=param.v2v, headers=config.Headers) r = requests.post(url=config.url_prod + config.v2v, data=param.v2v, headers=TestGatlingAPI.headers)
print(r.text) print(r.text)
assert r.status_code == 200 assert r.status_code == 200
def test_tv2(self): def test_tv2(self):
r = requests.post(url=config.url_prod + config.t2v, data=param.t2v, headers=config.Headers) r = requests.post(url=config.url_prod + config.t2v, data=param.t2v, headers=TestGatlingAPI.headers)
print(r.text) print(r.text)
assert r.status_code == 200 assert r.status_code == 200
{ {
"title_id": 20220340 "title_id": 20220358
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment