47 lines
1.5 KiB
Python
47 lines
1.5 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),
|
|
'price': 1999,
|
|
'old_price': 2008,
|
|
'quantity': 10,
|
|
'count': 0,
|
|
'model_id': 'model_006f52e9102a8d3be2fe5614f42ba989' # Смотри model.py,
|
|
'group_id': 'group_1679091c5a880faf6fb5e6087eb1b2dc', # Смотри group.py,
|
|
'factory_num': '123qbc',
|
|
'vendor_num': '123qbc',
|
|
'oem': '123qbc',
|
|
'comment': '123qbc',
|
|
'is_new': 0,
|
|
'is_original': 1,
|
|
'pictures_ids': [ # Смотри picture.py,
|
|
'picture_00003e3b9e5336685200ae85d21b4f5e',
|
|
'picture_000053b1e684c9e7ea73727b2238ce18',
|
|
'picture_0001261e2060303a06ba6c64d676d639',
|
|
'picture_00029153d12ae1c9abe59c17ff2e0895',
|
|
],
|
|
'characteristics': [
|
|
{
|
|
'key': 'chtitle_b28354b543375bfa94dabaeda722927f', # Смотри characteristic.py
|
|
'value': 'chvalue_a6105c0a611b41b08f1209506350279e', # Смотри value.py
|
|
}
|
|
]
|
|
}
|
|
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() |