From fbb8400f960179624c7348d3d7bf8fb85e09c7e0 Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Sun, 31 May 2015 17:42:22 +0200 Subject: [PATCH] [FIX] account: OFX import test --- .../tests/test_import_bank_statement.py | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/addons/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/addons/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 8b92b86e2b5..31a69f5a39c 100644 --- a/addons/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/addons/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -8,8 +8,8 @@ class TestOfxFile(TransactionCase): def setUp(self): super(TestOfxFile, self).setUp() - self.BankStatementImport = self.env['account.bank.statement.import'] - self.BankStatement = self.env['account.bank.statement'] + self.statement_import_model = self.env['account.bank.statement.import'] + self.bank_statement_model = self.env['account.bank.statement'] def test_ofx_file_import(self): try: @@ -19,10 +19,19 @@ class TestOfxFile(TransactionCase): return True ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx') ofx_file = open(ofx_file_path, 'rb').read().encode('base64') - bank_statement_id = self.BankStatementImport.create(dict( - data_file=ofx_file, - )) - bank_statement_id.import_file() - statement = self.BankStatement.search([('name', '=', '000000123')], limit=1) - self.assertEquals(statement.balance_start, 2516.56) - self.assertEquals(statement.balance_end_real, 2156.56) + + import_wizard = self.statement_import_model.create(dict(data_file=ofx_file)) + create_journal_wizard = self.env['account.bank.statement.import.journal.creation']\ + .with_context(statement_import_transient_id=import_wizard.id)\ + .create({'name': 'Bank 123456', 'currency_id': self.env.ref("base.USD").id, 'account_number': '123456'}) + create_journal_wizard.create_journal() # Note: also finishes import + bank_st_record = self.bank_statement_model.search([('name', '=', '000000123')])[0] + + self.assertEqual(bank_st_record.balance_start, 2516.56) + self.assertEqual(bank_st_record.balance_end_real, 2156.56) + + line = bank_st_record.line_ids[-1] + self.assertEqual(line.name, 'Agrolait') + self.assertEqual(line.ref, '219378') + self.assertEqual(line.partner_id.id, self.ref('base.res_partner_2')) + self.assertEqual(line.bank_account_id.id, self.ref('account_bank_statement_import.ofx_partner_bank_1')) \ No newline at end of file