def _simulate_preorder(self, client, product):
secret = get_random_string(32)
p = Preorder.objects.create(order_code=get_random_string(12), is_paid=True)
p.positions.create(secret=secret, product=product)
resp = client.post('/api/transactions/', json.dumps({
"positions": [
{"product": product.pk,
"price": "0.00",
"secret": secret,
"type": "redeem",
"_title": product.name}
]
}), content_type="application/json")
c = json.loads(resp.content.decode('utf-8'))
assert c['success']
return c['id']
评论列表
文章目录