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.

32 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. # noqa: This is a backport from Odoo. OCA has no control over style here.
  3. # flake8: noqa
  4. from openerp.tests.common import TransactionCase
  5. from openerp.modules.module import get_module_resource
  6. class TestOfxFile(TransactionCase):
  7. """Tests for import bank statement ofx file format (account.bank.statement.import)
  8. """
  9. def setUp(self):
  10. super(TestOfxFile, self).setUp()
  11. self.statement_import_model = self.registry('account.bank.statement.import')
  12. self.bank_statement_model = self.registry('account.bank.statement')
  13. def test_ofx_file_import(self):
  14. try:
  15. from ofxparse import OfxParser as ofxparser
  16. except ImportError:
  17. #the Python library isn't installed on the server, the OFX import is unavailable and the test cannot be run
  18. return True
  19. cr, uid = self.cr, self.uid
  20. ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx')
  21. ofx_file = open(ofx_file_path, 'rb').read().encode('base64')
  22. bank_statement_id = self.statement_import_model.create(cr, uid, dict(
  23. data_file=ofx_file,
  24. ))
  25. self.statement_import_model.import_file(cr, uid, [bank_statement_id])
  26. statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0]
  27. bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
  28. self.assertEquals(bank_st_record.balance_start, 2156.56)
  29. self.assertEquals(bank_st_record.balance_end_real, 1796.56)