Browse Source

FIX tests of import_save_file module to avoid conflicts with others

pull/202/head
Emanuel Cino 7 years ago
committed by Alexis de Lattre
parent
commit
cd45ccee10
  1. 19
      account_bank_statement_import_save_file/tests/test_save_file.py

19
account_bank_statement_import_save_file/tests/test_save_file.py

@ -9,13 +9,24 @@ from odoo.tests.common import TransactionCase
acc_number = 'BE1234567890'
module_name = 'account_bank_statement_import_save_file'
class HelloWorldParser(models.TransientModel):
""" Fake parser that will return custom data if the file contains the
name of the module. """
_inherit = 'account.bank.statement.import'
@api.model
def _parse_file(self, data_file):
if module_name in data_file:
return self._mock_parse(data_file)
else:
return super(HelloWorldParser, self)._parse_file(data_file)
def _mock_parse(self, data_file):
""" method that can be inherited in other tests to mock a statement
parser. """
return (
'EUR',
acc_number,
@ -48,11 +59,13 @@ class TestSaveFile(TransactionCase):
import_wizard = self.env['account.bank.statement.import']
journal_id = self.bank_journal_euro.id
import_wizard_id = import_wizard.with_context(journal_id=journal_id)\
.create(
{'data_file': base64.b64encode(bytes('Hello world'))})
.create({
'data_file': base64.b64encode(bytes(
'account_bank_statement_import_save_file: Hello world'))
})
action = import_wizard_id.import_file()
for statement in self.env['account.bank.statement'].browse(
action['context']['statement_ids']):
self.assertEqual(
base64.b64decode(statement.import_file.datas),
'Hello world')
'account_bank_statement_import_save_file: Hello world')
Loading…
Cancel
Save