40 lines
1.1 KiB
Python
40 lines
1.1 KiB
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 = 'product_' + id_generator(16)
|
|
data = {
|
|
'id': id,
|
|
'name': id_generator(16),
|
|
'tag': id_generator(16),
|
|
'price': 1999,
|
|
'old_price': 2008,
|
|
'quantity': 10,
|
|
'model_id': 'model_rxbvlglyao59ef2s',
|
|
'group_id': 'group_10c8f7l3lu7ydxhk',
|
|
'factory_num': '123qbc',
|
|
'vendor_num': '123qbc',
|
|
'oem': '123qbc',
|
|
'comment': '123qbc',
|
|
'is_new': 0,
|
|
'is_original': 1,
|
|
'pictures_ids': ['picture_75g36ayxk9yvl8lz', 'picture_bpjunqpy94k36got', 'picture_nxyrvt9hggw2rff2', 'picture_y04kt98ernepnh1y',],
|
|
'options': {
|
|
'left': 1,
|
|
'right': 0,
|
|
}
|
|
}
|
|
req = Request('POST', 'http://localhost/api/v1.0/show-case/product', json=data, auth=('qwe', 'qwe'))
|
|
prepped = req.prepare()
|
|
resp = s.send(prepped)
|
|
print(resp.status_code)
|
|
print(resp.json())
|
|
|
|
test() |