54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from trytond.tests.test_tryton import RouteTestCase
|
|
from trytond.pool import Pool
|
|
from http import HTTPStatus
|
|
import uuid
|
|
import json
|
|
from trytond.tests.test_tryton import DB_NAME
|
|
from trytond.transaction import Transaction
|
|
from trytond.modules.company.tests.tools import create_company
|
|
from trytond.tests.tools import activate_modules
|
|
|
|
|
|
class SaleOrderApiRouteTestCase(RouteTestCase):
|
|
"""Sale Order API Routes"""
|
|
|
|
module = 'sale_order'
|
|
key = uuid.uuid4().hex
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
activate_modules('sale_order', create_company)
|
|
|
|
def setUp(self):
|
|
pool = Pool(DB_NAME)
|
|
transaction = Transaction().start(DB_NAME, 0, _lock_tables=[
|
|
'product_product'])
|
|
with transaction:
|
|
Party = pool.get('party.party')
|
|
ProductTemplate = pool.get('product.template')
|
|
Product = pool.get('product.product')
|
|
Uom = pool.get('product.uom')
|
|
self.productTemplate, = ProductTemplate.create([{
|
|
'name': 'Product',
|
|
'default_uom': Uom.search([('name', '=', 'Unit')])[0].id,
|
|
}])
|
|
self.product, = Product.create([
|
|
{'template': self.productTemplate.id}
|
|
])
|
|
|
|
self.party, = Party.create([{
|
|
'name': "Dunkan"
|
|
}])
|
|
|
|
def test_post_sale_order(self):
|
|
client = self.client()
|
|
response = client.post(
|
|
f'/{self.db_name}/sale_order/order',
|
|
headers={
|
|
'Authorization': f'bearer {self.key}',
|
|
}, data=json.dumps({
|
|
"party": self.party.id,
|
|
}))
|
|
|
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|