Browse Source

[ADD] tests

pull/204/head
Holger Brunn 8 years ago
parent
commit
fb3589a96f
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 3
      account_bank_statement_import_auto_reconcile/__openerp__.py
  2. 9
      account_bank_statement_import_auto_reconcile/demo/account_bank_statement_import_auto_reconcile_rule.xml
  3. 61
      account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py

3
account_bank_statement_import_auto_reconcile/__openerp__.py

@ -13,6 +13,9 @@
'account_bank_statement_import', 'account_bank_statement_import',
'web_widget_one2many_tags', 'web_widget_one2many_tags',
], ],
"demo": [
"demo/account_bank_statement_import_auto_reconcile_rule.xml",
],
"data": [ "data": [
"views/account_bank_statement_import.xml", "views/account_bank_statement_import.xml",
"views/account_journal.xml", "views/account_journal.xml",

9
account_bank_statement_import_auto_reconcile/demo/account_bank_statement_import_auto_reconcile_rule.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="rule_amount_exact" model="account.bank.statement.import.auto.reconcile.rule">
<field name="journal_id" ref="account.bank_journal" />
<field name="rule_type">account.bank.statement.import.auto.reconcile.exact.amount</field>
</record>
</data>
</openerp>

61
account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py

@ -1,9 +1,68 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl> # © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import base64
from datetime import timedelta
from openerp import fields
from openerp.tests.common import TransactionCase from openerp.tests.common import TransactionCase
from openerp.addons.account_bank_statement_import.models\
.account_bank_statement_import import AccountBankStatementImport
class TestAccountBankStatementImportAutoReconcile(TransactionCase): class TestAccountBankStatementImportAutoReconcile(TransactionCase):
def setUp(self):
super(TestAccountBankStatementImportAutoReconcile, self).setUp()
# we don't really have something to import, so we patch the
# import routine to return what we want for our tests
self.original_parse_file = AccountBankStatementImport._parse_file
AccountBankStatementImport._parse_file = self._parse_file
self.invoice = self.env.ref('account.invoice_4')
def tearDown(self):
super(TestAccountBankStatementImportAutoReconcile, self).tearDown()
AccountBankStatementImport._parse_file = self.original_parse_file
def _parse_file(self, data):
date = self.invoice.date_invoice
return [
{
'currency_code': self.invoice.company_id.currency_id.name,
'account_number':
self.invoice.partner_id.bank_ids[:1].acc_number,
'name': 'Auto reconcile test',
'date': fields.Date.to_string(
fields.Date.from_string(date) + timedelta(days=5)
),
'transactions': [
{
'name': 'testtransaction',
'date': fields.Date.to_string(
fields.Date.from_string(date) + timedelta(days=5)
),
'amount': self.invoice.residual,
'unique_import_id': '42',
},
],
},
]
def test_account_bank_statement_import_auto_reconcile(self): def test_account_bank_statement_import_auto_reconcile(self):
pass
# first, we do an import with auto reconciliation turned off
action = self.env['account.bank.statement.import'].create({
'data_file': base64.b64encode('hello world'),
'journal_id': self.env.ref('account.bank_journal').id,
'auto_reconcile': False,
}).import_file()
# nothing should have happened
self.assertEqual(self.invoice.state, 'open')
self.env['account.bank.statement'].browse(
action['context']['statement_ids']
).unlink()
# for exact amount matching, our first transaction should be matched
# to the invoice's move line, marking the invoice as paid
action = self.env['account.bank.statement.import'].create({
'data_file': base64.b64encode('hello world'),
'journal_id': self.env.ref('account.bank_journal').id,
'auto_reconcile': True,
}).import_file()
self.assertEqual(self.invoice.state, 'paid')
Loading…
Cancel
Save