2
0

Better tests

This commit is contained in:
Andrea 2019-01-17 09:25:43 +01:00 committed by Andrea Stirpe
parent 8f85126e64
commit 76a63f40ee
3 changed files with 54 additions and 33 deletions

View File

@ -25,24 +25,31 @@ class TestAccountInvoiceSpread(common.TransactionCase):
type_receivable = self.env.ref('account.data_account_type_receivable')
type_payable = self.env.ref('account.data_account_type_payable')
def get_account(obj):
return self.env['account.account'].search([
('user_type_id', '=', obj.id),
('reconcile', '=', True),
], limit=1)
self.invoice_account = self.env['account.account'].create({
'name': 'test_account_receivable',
'code': '123',
'user_type_id': type_receivable.id,
'reconcile': True
})
self.invoice_account = get_account(type_receivable)
self.invoice_line_account = get_account(type_payable)
self.invoice_line_account = self.env['account.account'].create({
'name': 'test_account_payable',
'code': '321',
'user_type_id': type_payable.id,
'reconcile': True
})
self.spread_account = self.env['account.account'].search([
('user_type_id', '=', type_payable.id),
('id', '!=', self.invoice_line_account.id)
], limit=1)
self.spread_account = self.env['account.account'].create({
'name': 'test spread account_payable',
'code': '765',
'user_type_id': type_payable.id,
'reconcile': True
})
partner = self.env['res.partner'].create({
partner = self.env['res.partner'].create([{
'name': 'Partner Name',
'supplier': True,
})
}])
self.invoice = self.env['account.invoice'].create({
'partner_id': partner.id,
'account_id': self.invoice_account.id,

View File

@ -24,19 +24,25 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
super().setUp()
self._load('account', 'test', 'account_minimal_test.xml')
def get_account(obj):
return self.env['account.account'].search([
('user_type_id', '=', obj.id)
], limit=1)
type_receivable = self.env.ref('account.data_account_type_receivable')
type_expenses = self.env.ref('account.data_account_type_expenses')
self.credit_account = get_account(type_receivable)
self.debit_account = get_account(type_expenses)
self.credit_account = self.env['account.account'].create({
'name': 'test_account_receivable',
'code': '123',
'user_type_id': type_receivable.id,
'reconcile': True
})
self.debit_account = self.env['account.account'].create({
'name': 'test account_expenses',
'code': '765',
'user_type_id': type_expenses.id,
'reconcile': True
})
def test_01_account_spread_defaults(self):
this_year = datetime.date.today().year
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
@ -65,7 +71,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
self.assertEqual(spread.unposted_amount, 0.)
self.assertEqual(spread.total_amount, 0.)
self.assertEqual(spread.estimated_amount, 0.)
self.assertEqual(spread.spread_date, datetime.date(2018, 1, 1))
self.assertEqual(spread.spread_date, datetime.date(this_year, 1, 1))
self.assertTrue(spread.journal_id)
self.assertEqual(spread.journal_id.type, 'general')

View File

@ -14,22 +14,30 @@ class TestComputeSpreadBoard(common.TransactionCase):
type_receivable = self.env.ref('account.data_account_type_receivable')
type_expenses = self.env.ref('account.data_account_type_expenses')
def get_account(obj):
return self.env['account.account'].search([
('user_type_id', '=', obj.id)
], limit=1)
journal = self.env['account.journal'].search([
('type', '=', 'general')],
limit=1)
self.receivable_account = get_account(type_receivable)
self.expense_account = get_account(type_expenses)
self.receivable_account = self.env['account.account'].create({
'name': 'test_account_receivable',
'code': '123',
'user_type_id': type_receivable.id,
'reconcile': True
})
self.spread_account = self.env['account.account'].search([
('user_type_id', '=', type_expenses.id),
('id', '!=', self.expense_account.id)
], limit=1)
self.expense_account = self.env['account.account'].create({
'name': 'test account_expenses',
'code': '765',
'user_type_id': type_expenses.id,
'reconcile': True
})
self.spread_account = self.env['account.account'].create({
'name': 'test spread account_expenses',
'code': '321',
'user_type_id': type_expenses.id,
'reconcile': True
})
self.spread = self.env['account.spread'].create({
'name': 'test',