[FIX] account_statement_import_online: use unittest.mock and don't import tests at install

Installing this module failed because `mock` couldn't be found. Indeed there was a migration problem.

However, I was not testing the module; just installing. At install, tests shouldn't be imported.

This file was being imported because the dummy model was expected to exist in database for tests. Using odoo-test-helper for that now.

@moduon MT-295
This commit is contained in:
Jairo Llopis
2022-03-09 11:32:07 +00:00
committed by Carolina Fernandez
parent dc844e6c16
commit f2be23d41f
4 changed files with 24 additions and 14 deletions

View File

@@ -2,4 +2,3 @@
from . import models
from . import wizards
from .tests import online_bank_statement_provider_dummy

View File

@@ -4,13 +4,14 @@
{
"name": "Online Bank Statements",
"version": "14.0.2.1.0",
"version": "14.0.2.1.1",
"author": "CorporateHub, Odoo Community Association (OCA)",
"maintainers": ["alexey-pelykh"],
"website": "https://github.com/OCA/bank-statement-import",
"license": "AGPL-3",
"category": "Accounting",
"summary": "Online bank statements update",
"external_dependencies": {"python": ["odoo_test_helper"]},
"depends": [
"account",
"account_statement_import",

View File

@@ -7,6 +7,7 @@ from unittest import mock
from urllib.error import HTTPError
from dateutil.relativedelta import relativedelta
from odoo_test_helper import FakeModelLoader
from psycopg2 import IntegrityError
from odoo import fields
@@ -20,18 +21,27 @@ mock_obtain_statement_data = (
)
class TestAccountBankAccountStatementImportOnline(common.TransactionCase):
def setUp(self):
super().setUp()
class TestAccountBankAccountStatementImportOnline(common.SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
self.now = fields.Datetime.now()
self.AccountJournal = self.env["account.journal"]
self.OnlineBankStatementProvider = self.env["online.bank.statement.provider"]
self.OnlineBankStatementPullWizard = self.env[
"online.bank.statement.pull.wizard"
]
self.AccountBankStatement = self.env["account.bank.statement"]
self.AccountBankStatementLine = self.env["account.bank.statement.line"]
# Load fake model
cls.loader = FakeModelLoader(cls.env, cls.__module__)
cls.loader.backup_registry()
cls.addClassCleanup(cls.loader.restore_registry)
from .online_bank_statement_provider_dummy import (
OnlineBankStatementProviderDummy,
)
cls.loader.update_registry((OnlineBankStatementProviderDummy,))
cls.now = fields.Datetime.now()
cls.AccountJournal = cls.env["account.journal"]
cls.OnlineBankStatementProvider = cls.env["online.bank.statement.provider"]
cls.OnlineBankStatementPullWizard = cls.env["online.bank.statement.pull.wizard"]
cls.AccountBankStatement = cls.env["account.bank.statement"]
cls.AccountBankStatementLine = cls.env["account.bank.statement.line"]
def test_provider_unlink_restricted(self):
journal = self.AccountJournal.create(

View File

@@ -1,6 +1,6 @@
# Copyright 2021 Therp BV (https://therp.nl).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from mock import patch
from unittest.mock import patch
from odoo.tests import common