-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by huguesdk
- Loading branch information
Showing
6 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import company | ||
from . import subscription_request | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Copyright 2019 Coop IT Easy SCRL fs | ||
# Houssine Bakkali <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import test_cooperator_national_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# Copyright 2019 Coop IT Easy SCRL fs | ||
# Robin Keunen <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from unittest import mock | ||
|
||
from odoo.exceptions import UserError, ValidationError | ||
from odoo.tests.common import TransactionCase | ||
|
@@ -9,6 +11,10 @@ | |
|
||
NATIONAL_NUMBER = 90010100123 | ||
|
||
account_move_action_post = ( | ||
"odoo.addons.account.models.account_move.AccountMove.action_post" | ||
) | ||
|
||
|
||
class TestCooperatorNationalNumber(TransactionCase, CooperatorTestMixin): | ||
@classmethod | ||
|
@@ -73,6 +79,27 @@ def test_no_national_number_provided(self): | |
with self.assertRaises(UserError): | ||
subscription_request.validate_subscription_request() | ||
|
||
@mock.patch(account_move_action_post) | ||
def test_invalid_national_number_provided(self, account_move_action_post_mock): | ||
""" | ||
Providing an invalid national number should raise a validation error. | ||
""" | ||
self.set_national_number_required() | ||
vals = self.get_dummy_subscription_requests_vals() | ||
subscription_request = self.env["subscription.request"].create(vals) | ||
subscription_request.national_number = "42" | ||
with self.assertRaises(ValidationError): | ||
subscription_request.validate_subscription_request() | ||
# no capital release requests should be created or posted | ||
capital_release_requests = self.env["account.move"].search( | ||
[("subscription_request", "=", subscription_request.id)] | ||
) | ||
self.assertFalse(capital_release_requests) | ||
# mocking account.move.create() would be better, but if it is called, | ||
# the error is confusing: psycopg2.ProgrammingError: can't adapt type | ||
# 'MagicMock' | ||
account_move_action_post_mock.assert_not_called() | ||
|
||
def test_national_number_provided_not_required(self): | ||
"""Expect no error when a number is given but not required.""" | ||
vals = self.get_dummy_subscription_requests_vals() | ||
|