From f21041e2a73a62099c70c1edfb79fd5a47865b78 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 15 May 2020 11:15:02 +0200 Subject: [PATCH] save_file: remove test Porting these tests to v12 is quite complex. I don't think it's worth have such technically complex test for so few lines of code. We could move the test in a module that implement a bank statement format. --- .../tests/__init__.py | 1 - .../tests/test_save_file.py | 69 ------------------- 2 files changed, 70 deletions(-) delete mode 100644 account_bank_statement_import_save_file/tests/__init__.py delete mode 100644 account_bank_statement_import_save_file/tests/test_save_file.py diff --git a/account_bank_statement_import_save_file/tests/__init__.py b/account_bank_statement_import_save_file/tests/__init__.py deleted file mode 100644 index 4859e86..0000000 --- a/account_bank_statement_import_save_file/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_save_file diff --git a/account_bank_statement_import_save_file/tests/test_save_file.py b/account_bank_statement_import_save_file/tests/test_save_file.py deleted file mode 100644 index 41b957c..0000000 --- a/account_bank_statement_import_save_file/tests/test_save_file.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2015-2019 Therp BV (). -# Copyright 2017-Today Mourad EL HADJ MIMOUNE -# -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -import base64 -from odoo import api, models -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 data_file == module_name.encode('utf-8'): - 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, - [{ - 'name': '000000123', - 'date': '2013-06-26', - 'transactions': [{ - 'name': 'KBC-INVESTERINGSKREDIET 787-5562831-01', - 'date': '2013-06-26', - 'amount': 42, - 'unique_import_id': 'hello', - }], - }], - ) - - -class TestSaveFile(TransactionCase): - def setUp(self): - super(TestSaveFile, self).setUp() - self.currency_eur_id = self.env.ref("base.EUR").id - self.bank_journal_euro = self.env['account.journal'].create( - {'name': 'Bank', - 'type': 'bank', - 'code': 'BNK_test_imp', - 'currency_id': self.currency_eur_id - }) - - def test_SaveFile(self): - HelloWorldParser._build_model(self.registry, self.cr) - import_wizard = self.env['account.bank.statement.import'] - journal_id = self.bank_journal_euro.id - data_file = base64.b64encode(module_name.encode('utf-8')) - import_wizard_id = import_wizard.with_context(journal_id=journal_id)\ - .create({'data_file': data_file, 'filename': 'test.ofx'}) - 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), - module_name.encode('utf-8'))