/usr/lib/python2.7/dist-packages/trytond/modules/product_price_list/tests/test_product_price_list.py is in tryton-modules-product-price-list 4.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from decimal import Decimal
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.pool import Pool
from trytond.modules.company.tests import create_company, set_company
class ProductPriceListTestCase(ModuleTestCase):
'Test ProductPriceList module'
module = 'product_price_list'
@with_transaction()
def test_price_list(self):
'Test price_list'
pool = Pool()
Template = pool.get('product.template')
Product = pool.get('product.product')
Party = pool.get('party.party')
Uom = pool.get('product.uom')
PriceList = pool.get('product.price_list')
company = create_company()
with set_company(company):
party = Party(name='Customer')
party.save()
kilogram, = Uom.search([
('name', '=', 'Kilogram'),
])
gram, = Uom.search([
('name', '=', 'Gram'),
])
template = Template(
name='Test Lot Sequence',
list_price=Decimal(10),
cost_price=Decimal(5),
default_uom=kilogram,
)
template.save()
product = Product(template=template)
product.save()
variant = Product(template=template)
variant.save()
price_list, = PriceList.create([{
'name': 'Default Price List',
'lines': [('create', [{
'quantity': 10.0,
'product': variant.id,
'formula': 'unit_price * 0.8',
}, {
'quantity': 10.0,
'formula': 'unit_price * 0.9',
}, {
'product': variant.id,
'formula': 'unit_price * 1.1',
}, {
'formula': 'unit_price',
}])],
}])
tests = [
(product, 1.0, kilogram, Decimal(10.0)),
(product, 1000.0, gram, Decimal(10.0)),
(variant, 1.0, kilogram, Decimal(11.0)),
(product, 10.0, kilogram, Decimal(9.0)),
(product, 10000.0, gram, Decimal(9.0)),
(variant, 10.0, kilogram, Decimal(8.0)),
(variant, 10000.0, gram, Decimal(8.0)),
]
for product, quantity, unit, result in tests:
self.assertEqual(
price_list.compute(party, product, product.list_price,
quantity, unit),
result)
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
ProductPriceListTestCase))
return suite
|