first commit
This commit is contained in:
2
modules/timesheet_cost/tests/__init__.py
Normal file
2
modules/timesheet_cost/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
52
modules/timesheet_cost/tests/test_module.py
Normal file
52
modules/timesheet_cost/tests/test_module.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# 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 datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, create_company, create_employee, set_company)
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class TimesheetCostTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test TimesheetCost module'
|
||||
module = 'timesheet_cost'
|
||||
|
||||
@with_transaction()
|
||||
def test_compute_cost_price(self):
|
||||
'Test compute_cost_price'
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
EmployeeCostPrice = pool.get('company.employee_cost_price')
|
||||
|
||||
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)),
|
||||
]
|
||||
party = Party(name='Pam Beesly')
|
||||
party.save()
|
||||
company = create_company()
|
||||
with set_company(company):
|
||||
employee = create_employee(company)
|
||||
for date, cost_price in cost_prices:
|
||||
EmployeeCostPrice(
|
||||
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
|
||||
Reference in New Issue
Block a user