mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[FIX] Restructure and expand tests. Fix some bugs.
There is now a common class to test import of statements and their transactions. Fixes: - Field in regular expression for mt940 rabo parser was to short for bank-account. - Wrong name used for reference attribute in mt940 rabo parser; - Attribute transferred_amount should not have been renamed amount in BankTransaction.
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#
|
||||
# Copyright (C) 2015 Therp BV <http://therp.nl>.
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
@@ -20,45 +18,28 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.modules.module import get_module_resource
|
||||
from openerp.addons.account_bank_statement_import.tests import (
|
||||
TestStatementFile)
|
||||
|
||||
|
||||
class TestStatementFile(TransactionCase):
|
||||
"""Run test to import camt.053 import."""
|
||||
class TestImport(TestStatementFile):
|
||||
"""Run test to import camt import."""
|
||||
|
||||
def test_statement_import(self):
|
||||
"""Test correct creation of single statement."""
|
||||
import_model = self.registry('account.bank.statement.import')
|
||||
statement_model = self.registry('account.bank.statement')
|
||||
cr, uid = self.cr, self.uid
|
||||
statement_path = get_module_resource(
|
||||
'bank_statement_parse_camt',
|
||||
'test_files',
|
||||
'test-camt053.xml'
|
||||
)
|
||||
statement_file = open(
|
||||
statement_path, 'rb').read().encode('base64')
|
||||
bank_statement_id = import_model.create(
|
||||
cr, uid,
|
||||
dict(
|
||||
data_file=statement_file,
|
||||
)
|
||||
)
|
||||
import_model.import_file(cr, uid, [bank_statement_id])
|
||||
ids = statement_model.search(
|
||||
cr, uid, [('name', '=', '1234Test/1')])
|
||||
self.assertTrue(ids, 'Statement not found after parse.')
|
||||
statement_id = ids[0]
|
||||
statement_obj = statement_model.browse(
|
||||
cr, uid, statement_id)
|
||||
self.assertTrue(
|
||||
abs(statement_obj.balance_start - 15568.27) < 0.00001,
|
||||
'Start balance %f not equal to 15568.27' %
|
||||
statement_obj.balance_start
|
||||
)
|
||||
self.assertTrue(
|
||||
abs(statement_obj.balance_end_real - 15121.12) < 0.00001,
|
||||
'Real end balance %f not equal to 15121.12' %
|
||||
statement_obj.balance_end_real
|
||||
transactions = [
|
||||
{
|
||||
'remote_account': 'NL46ABNA0499998748',
|
||||
'transferred_amount': -754.25,
|
||||
'value_date': '2013-01-05',
|
||||
'ref': '435005714488-ABNO33052620',
|
||||
},
|
||||
]
|
||||
# statement name is account number + '-' + date of last 62F line:
|
||||
self._test_statement_import(
|
||||
'bank_statement_parse_camt', 'test-camt053.xml',
|
||||
'1234Test/1',
|
||||
local_account='NL77ABNA0574908765',
|
||||
start_balance=15568.27, end_balance=15121.12,
|
||||
transactions=transactions
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user