/usr/lib/python2.7/dist-packages/trytond/modules/carrier_percentage/tests/test_carrier_percentage.py is in tryton-modules-carrier-percentage 3.4.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 87 88 89 90 91 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import unittest
import doctest
from decimal import Decimal
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
test_view, test_depends, doctest_setup, doctest_teardown
from trytond.transaction import Transaction
class CarrierWeightTestCase(unittest.TestCase):
'Test CarrierWeight module'
def setUp(self):
trytond.tests.test_tryton.install_module('carrier_percentage')
self.party = POOL.get('party.party')
self.uom = POOL.get('product.uom')
self.template = POOL.get('product.template')
self.product = POOL.get('product.product')
self.category = POOL.get('product.category')
self.currency = POOL.get('currency.currency')
self.carrier = POOL.get('carrier')
def test0005views(self):
'Test views'
test_view('carrier_percentage')
def test0006depends(self):
'Test depends'
test_depends()
def test0010compute_percentage(self):
'Test compute_percentage'
with Transaction().start(DB_NAME, USER, context=CONTEXT):
party, = self.party.create([{
'name': 'Carrier',
}])
uom, = self.uom.search([
('name', '=', 'Unit'),
])
category, = self.category.create([{
'name': 'Category',
}])
template, = self.template.create([{
'name': 'Carrier',
'default_uom': uom.id,
'category': category.id,
'type': 'service',
'list_price': Decimal(0),
'cost_price': Decimal(0),
}])
product, = self.product.create([{
'template': template.id,
}])
currency, = self.currency.search([
('code', '=', 'cu1'),
])
carrier, = self.carrier.create([{
'party': party.id,
'carrier_product': product.id,
'carrier_cost_method': 'percentage',
'percentage': Decimal(15),
}])
for amount, price in [
(Decimal(0), Decimal(0)),
(Decimal(100), Decimal('15.00')),
(Decimal(150), Decimal('22.50')),
]:
self.assertEqual(
carrier.compute_percentage(amount, currency.id),
(price, currency.id))
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.product.tests import test_product
for test in test_product.suite():
if test not in suite:
suite.addTest(test)
from trytond.modules.currency.tests import test_currency
for test in test_currency.suite():
if test not in suite:
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
CarrierWeightTestCase))
suite.addTests(doctest.DocFileSuite(
'scenario_carrier_percentage_with_purchase_shipment_cost.rst',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite
|