spavto_tests/model.py

28 lines
749 B
Python

from requests import Request, Session
import hashlib
import string
import random
s = Session()
def id_generator(size=6, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
def test():
id = 'model_' + id_generator(16)
data = {
'id': id,
'name': id_generator(16),
'url': id_generator(16),
'year_from': 1999,
'year_to': 2008,
'brand_id': 'brand_rbmjh7flxc9zgr0r',
'picture_id': 'picture_75g36ayxk9yvl8lz',
}
req = Request('POST', 'http://localhost/api/v1.0/show-case/model', json=data, auth=('qwe', 'qwe'))
prepped = req.prepare()
resp = s.send(prepped)
print(resp.status_code)
print(resp.json())
test()