Files
tryton/modules/timesheet_cost/tests/test_module.py
T

53 lines
1.9 KiB
Python
Raw Normal View History

2014-12-02 12:56:22 +01:00
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
2013-07-14 10:42:07 +02:00
import datetime
from decimal import Decimal
2019-08-08 08:29:55 +02:00
from trytond.modules.company.tests import (
2021-12-11 17:58:45 +01:00
CompanyTestMixin, create_company, create_employee, set_company)
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
2013-07-14 10:42:07 +02:00
class TimesheetCostTestCase(CompanyTestMixin, ModuleTestCase):
2014-01-12 20:00:26 +01:00
'Test TimesheetCost module'
2015-01-27 18:14:23 +01:00
module = 'timesheet_cost'
2013-07-14 10:42:07 +02:00
2016-02-06 19:13:32 +01:00
@with_transaction()
def test_compute_cost_price(self):
2014-01-12 20:00:26 +01:00
'Test compute_cost_price'
2016-02-06 19:13:32 +01:00
pool = Pool()
Party = pool.get('party.party')
EmployeeCostPrice = pool.get('company.employee_cost_price')
2013-07-14 10:42:07 +02:00
cost_prices = [
(datetime.date(2011, 1, 1), Decimal(10)),
(datetime.date(2012, 1, 1), Decimal(15)),
(datetime.date(2013, 1, 1), Decimal(20)),
]
test_prices = [
(datetime.date(2010, 1, 1), 0),
(datetime.date(2011, 1, 1), Decimal(10)),
(datetime.date(2011, 6, 1), Decimal(10)),
(datetime.date(2012, 1, 1), Decimal(15)),
(datetime.date(2012, 6, 1), Decimal(15)),
(datetime.date(2013, 1, 1), Decimal(20)),
(datetime.date(2013, 6, 1), Decimal(20)),
]
2016-02-06 19:13:32 +01:00
party = Party(name='Pam Beesly')
party.save()
company = create_company()
with set_company(company):
2019-08-08 08:29:55 +02:00
employee = create_employee(company)
2013-07-14 10:42:07 +02:00
for date, cost_price in cost_prices:
2016-02-06 19:13:32 +01:00
EmployeeCostPrice(
2013-07-14 10:42:07 +02:00
employee=employee,
date=date,
cost_price=cost_price).save()
for date, cost_price in test_prices:
self.assertEqual(employee.compute_cost_price(date), cost_price)
del ModuleTestCase