mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[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:
committed by
Carolina Fernandez
parent
dc844e6c16
commit
f2be23d41f
@@ -2,4 +2,3 @@
|
|||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
from .tests import online_bank_statement_provider_dummy
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Online Bank Statements",
|
"name": "Online Bank Statements",
|
||||||
"version": "14.0.2.1.0",
|
"version": "14.0.2.1.1",
|
||||||
"author": "CorporateHub, Odoo Community Association (OCA)",
|
"author": "CorporateHub, Odoo Community Association (OCA)",
|
||||||
"maintainers": ["alexey-pelykh"],
|
"maintainers": ["alexey-pelykh"],
|
||||||
"website": "https://github.com/OCA/bank-statement-import",
|
"website": "https://github.com/OCA/bank-statement-import",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "Accounting",
|
"category": "Accounting",
|
||||||
"summary": "Online bank statements update",
|
"summary": "Online bank statements update",
|
||||||
|
"external_dependencies": {"python": ["odoo_test_helper"]},
|
||||||
"depends": [
|
"depends": [
|
||||||
"account",
|
"account",
|
||||||
"account_statement_import",
|
"account_statement_import",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from unittest import mock
|
|||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from odoo_test_helper import FakeModelLoader
|
||||||
from psycopg2 import IntegrityError
|
from psycopg2 import IntegrityError
|
||||||
|
|
||||||
from odoo import fields
|
from odoo import fields
|
||||||
@@ -20,18 +21,27 @@ mock_obtain_statement_data = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestAccountBankAccountStatementImportOnline(common.TransactionCase):
|
class TestAccountBankAccountStatementImportOnline(common.SavepointCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super().setUp()
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
|
||||||
self.now = fields.Datetime.now()
|
# Load fake model
|
||||||
self.AccountJournal = self.env["account.journal"]
|
cls.loader = FakeModelLoader(cls.env, cls.__module__)
|
||||||
self.OnlineBankStatementProvider = self.env["online.bank.statement.provider"]
|
cls.loader.backup_registry()
|
||||||
self.OnlineBankStatementPullWizard = self.env[
|
cls.addClassCleanup(cls.loader.restore_registry)
|
||||||
"online.bank.statement.pull.wizard"
|
from .online_bank_statement_provider_dummy import (
|
||||||
]
|
OnlineBankStatementProviderDummy,
|
||||||
self.AccountBankStatement = self.env["account.bank.statement"]
|
)
|
||||||
self.AccountBankStatementLine = self.env["account.bank.statement.line"]
|
|
||||||
|
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):
|
def test_provider_unlink_restricted(self):
|
||||||
journal = self.AccountJournal.create(
|
journal = self.AccountJournal.create(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Copyright 2021 Therp BV (https://therp.nl).
|
# Copyright 2021 Therp BV (https://therp.nl).
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# 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
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user