-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base_user_empty_password: add testcase
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_user_empty_password |
39 changes: 39 additions & 0 deletions
39
base_user_empty_password/tests/test_user_empty_password.py
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.exceptions import UserError | ||
|
||
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo | ||
|
||
|
||
class TestUserEmptyPassword(SavepointCaseWithUserDemo): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.wizard_model = cls.env["empty.password.wizard"] | ||
|
||
def test_empty_password_button(self): | ||
"""Test that the wizard's default_get correctly assigns user_ids.""" | ||
context = { | ||
"active_model": "res.users", | ||
"active_ids": [self.user_demo.id], | ||
} | ||
|
||
wizard = self.wizard_model.with_context(**context).create({}) | ||
|
||
wizard.empty_password_button() | ||
|
||
self.assertIn(self.user_demo, wizard.user_ids) | ||
self.assertFalse(self.user_demo.has_password) | ||
|
||
def test_invalid_model(self): | ||
"""Test that the wizard raises a UserError | ||
when active_model is not res.users. | ||
""" | ||
context = { | ||
"active_model": "res.partner", | ||
"active_ids": [self.user_demo.id], | ||
} | ||
|
||
with self.assertRaises(UserError): | ||
self.wizard_model.with_context(**context).create({}) |