feat: Delete Order, Delete Order Line
This commit is contained in:
@@ -3,57 +3,73 @@ import requests
|
||||
import json
|
||||
|
||||
|
||||
url = 'http://localhost:8000'
|
||||
key = 'f46f14d77db646b0ac0802e7bdab9cbb' + (
|
||||
'1d53ad96387242e1918c45854dce5238707fed31daa64cab88569d119512153') + (
|
||||
'64db6ced393b44f198ab9a3967b6f4ddf')
|
||||
db = 'tryton'
|
||||
application_name = 'sale_order'
|
||||
base_url = '{}/{}/{}'.format(url, db, application_name)
|
||||
url = "http://localhost:8000"
|
||||
key = (
|
||||
"f46f14d77db646b0ac0802e7bdab9cbb"
|
||||
+ ("1d53ad96387242e1918c45854dce5238707fed31daa64cab88569d119512153")
|
||||
+ ("64db6ced393b44f198ab9a3967b6f4ddf")
|
||||
)
|
||||
db = "tryton"
|
||||
application_name = "sale_order"
|
||||
base_url = "{}/{}/{}".format(url, db, application_name)
|
||||
|
||||
|
||||
get_associate_party = requests.get(
|
||||
base_url + '/associate_party/alejandro.ayala@gmail.com',
|
||||
base_url + "/associate_party/alejandro.ayala@gmail.com",
|
||||
headers={
|
||||
'Authorization': f'bearer {key}',
|
||||
})
|
||||
"Authorization": f"bearer {key}",
|
||||
},
|
||||
)
|
||||
|
||||
post_sale_order = requests.post(
|
||||
base_url + '/order',
|
||||
headers={
|
||||
'Authorization': f'bearer {key}',
|
||||
}, data=json.dumps({
|
||||
"party": 2573,
|
||||
"pickup_location": 'on_site',
|
||||
"lines": [[
|
||||
"create", [{
|
||||
"product": "1",
|
||||
"unit": "1",
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}]]]
|
||||
})
|
||||
base_url + "/order",
|
||||
headers={
|
||||
"Authorization": f"bearer {key}",
|
||||
},
|
||||
data=json.dumps(
|
||||
{
|
||||
"party": 2573,
|
||||
"pickup_location": "on_site",
|
||||
"lines": [
|
||||
[
|
||||
"create",
|
||||
[
|
||||
{
|
||||
"product": "1",
|
||||
"unit": "1",
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}],
|
||||
]
|
||||
],
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
order = json.loads(json.loads(post_sale_order.text)[0]).get("id")
|
||||
|
||||
get_sale_order = requests.get(
|
||||
base_url + '/order/1',
|
||||
base_url + "/order/1",
|
||||
headers={
|
||||
'Authorization': f'bearer {key}',
|
||||
})
|
||||
"Authorization": f"bearer {key}",
|
||||
},
|
||||
)
|
||||
|
||||
post_line_order = requests.post(
|
||||
base_url.replace(
|
||||
'sale_don_confiao', 'sale_order') + f'/{order}/order_line',
|
||||
headers={
|
||||
'Authorization': f'bearer {key}',
|
||||
}, data=json.dumps({
|
||||
"order": order,
|
||||
"product": "1",
|
||||
"unit": "1",
|
||||
"quantity": "5",
|
||||
"unitprice": "10"
|
||||
}))
|
||||
base_url.replace(
|
||||
"sale_don_confiao", "sale_order") + f"/{order}/order_line",
|
||||
headers={
|
||||
"Authorization": f"bearer {key}",
|
||||
},
|
||||
data=json.dumps(
|
||||
{
|
||||
"order": order,
|
||||
"product": "1",
|
||||
"unit": "1",
|
||||
"quantity": "5",
|
||||
"unitprice": "10",
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
pudb.set_trace()
|
||||
|
||||
@@ -47,16 +47,22 @@ class SaleOrderApiRouteTestCase(RouteTestCase):
|
||||
}
|
||||
]
|
||||
)
|
||||
self.product, = Product.create([
|
||||
{"template": self.productTemplate.id}])
|
||||
(self.product,) = Product.create([
|
||||
{"template": self.productTemplate.id}
|
||||
])
|
||||
|
||||
self.party, = Party.create([{
|
||||
"name": "Dunkan",
|
||||
"contact_mechanisms": [['create', [{
|
||||
'type': 'mobile',
|
||||
'value': '3102223334'
|
||||
}]]]
|
||||
}])
|
||||
(self.party,) = Party.create(
|
||||
[
|
||||
{
|
||||
"name": "Dunkan",
|
||||
"contact_mechanisms": [[
|
||||
"create", [{
|
||||
"type": "mobile",
|
||||
"value": "3102223334"}]]
|
||||
],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
def test_post_sale_order(self):
|
||||
client = self.client()
|
||||
@@ -228,8 +234,10 @@ class SaleOrderApiRouteTestCase(RouteTestCase):
|
||||
|
||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||
self.assertEqual(json.loads(response.text)[1], 200)
|
||||
self.assertEqual(json.loads(json.loads(response.text)[0])[
|
||||
'associate_party'], 2)
|
||||
self.assertEqual(json.loads(
|
||||
json.loads(
|
||||
response.text
|
||||
)[0])["associate_party"], 2)
|
||||
|
||||
def test_create_contact_method(self):
|
||||
"""
|
||||
@@ -240,3 +248,44 @@ class SaleOrderApiRouteTestCase(RouteTestCase):
|
||||
Return:
|
||||
party: int
|
||||
"""
|
||||
|
||||
def test_delete_sale(self):
|
||||
client = self.client()
|
||||
order = json.loads(
|
||||
client.post(
|
||||
f"/{self.db_name}/sale_order/order",
|
||||
headers={
|
||||
"Authorization": f"bearer {self.key}",
|
||||
},
|
||||
data=json.dumps(
|
||||
{
|
||||
"party": self.party.id,
|
||||
"pickup_location": "on_site",
|
||||
"lines": [
|
||||
[
|
||||
"create",
|
||||
[
|
||||
{
|
||||
"product": self.product.id,
|
||||
"unit": self.unit,
|
||||
"quantity": "5",
|
||||
"unitprice": "10",
|
||||
}
|
||||
],
|
||||
]
|
||||
],
|
||||
}
|
||||
),
|
||||
)
|
||||
.get_data()
|
||||
.decode()
|
||||
)
|
||||
|
||||
order_id = json.loads(order[0])["id"] # Get the id of the order
|
||||
delete_order = client.delete(
|
||||
f"/{self.db_name}/sale_order/{order_id}",
|
||||
headers={"Authorization": f"bearer {self.key}"},
|
||||
)
|
||||
|
||||
self.assertEqual(delete_order.status_code, HTTPStatus.OK)
|
||||
self.assertEqual(json.loads(delete_order.text)[1], 200)
|
||||
|
||||
Reference in New Issue
Block a user