You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp.tests.common import TransactionCase
  3. from openerp.modules.module import get_module_resource
  4. class TestOfxFile(TransactionCase):
  5. """Tests for import bank statement ofx file format
  6. (account.bank.statement.import)
  7. """
  8. def setUp(self):
  9. super(TestOfxFile, self).setUp()
  10. self.statement_import_model = self.env['account.bank.statement.import']
  11. self.bank_statement_model = self.env['account.bank.statement']
  12. def test_ofx_file_import(self):
  13. ofx_file_path = get_module_resource(
  14. 'account_bank_statement_import_ofx',
  15. 'test_ofx_file', 'test_ofx.ofx')
  16. ofx_file = open(ofx_file_path, 'rb').read().encode('base64')
  17. bank_statement = self.statement_import_model.create(
  18. dict(data_file=ofx_file))
  19. bank_statement.import_file()
  20. bank_st_record = self.bank_statement_model.search(
  21. [('name', '=', '123456')])[0]
  22. self.assertEquals(bank_st_record.balance_start, 2516.56)
  23. self.assertEquals(bank_st_record.balance_end_real, 2156.56)
  24. line = bank_st_record.line_ids[0]
  25. self.assertEquals(line.name, 'Agrolait')
  26. self.assertEquals(line.ref, '219378')
  27. self.assertEquals(line.partner_id.id, self.ref('base.res_partner_2'))
  28. self.assertEquals(
  29. line.bank_account_id.id,
  30. self.ref('account_bank_statement_import.ofx_partner_bank_1'))