Skip to content

Commit efce3f9

Browse files
committed
[IMP] pos_user_restriction: Improve tests
Changes done: - Remove context (TestPoSCommon already has it) - Use the new_test_user() method to create users - Use the BaseCommon class
1 parent 0e46509 commit efce3f9

2 files changed

Lines changed: 17 additions & 55 deletions

File tree

pos_user_restriction/tests/test_hacks.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo.tests import tagged
1+
from odoo.tests import new_test_user, tagged
22

33
from odoo.addons.point_of_sale.tests.common import TestPoSCommon
44

@@ -8,29 +8,10 @@ class TestHacks(TestPoSCommon):
88
@classmethod
99
def setUpClass(cls):
1010
super().setUpClass()
11-
cls.env = cls.env(
12-
context=dict(
13-
cls.env.context,
14-
tracking_disable=True,
15-
no_reset_password=True,
16-
)
17-
)
18-
cls.pos_user_assigned_pos = cls.env["res.users"].create(
19-
{
20-
"login": "pos_user_assigned_pos",
21-
"name": "pos_user_assigned_pos",
22-
"groups_id": [
23-
(
24-
6,
25-
0,
26-
[
27-
cls.env.ref(
28-
"pos_user_restriction.group_assigned_points_of_sale_user"
29-
).id
30-
],
31-
)
32-
],
33-
}
11+
cls.pos_user_assigned_pos = new_test_user(
12+
cls.env,
13+
login="pos_user_assigned_pos",
14+
groups="pos_user_restriction.group_assigned_points_of_sale_user",
3415
)
3516
cls.config = cls.basic_config
3617

pos_user_restriction/tests/test_pos_user_restriction.py

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
1-
from odoo.tests.common import TransactionCase
1+
from odoo.tests import new_test_user
22

3+
from odoo.addons.base.tests.common import BaseCommon
34

4-
class TestUserRestriction(TransactionCase):
5+
6+
class TestUserRestriction(BaseCommon):
57
@classmethod
68
def setUpClass(cls):
79
super().setUpClass()
8-
cls.env = cls.env(
9-
context=dict(
10-
cls.env.context,
11-
tracking_disable=True,
12-
no_reset_password=True,
13-
)
14-
)
15-
cls.pos_user = cls.env["res.users"].create(
16-
{
17-
"login": "pos_user",
18-
"name": "pos_user",
19-
"groups_id": [(6, 0, [cls.env.ref("point_of_sale.group_pos_user").id])],
20-
}
10+
cls.pos_user = new_test_user(
11+
cls.env,
12+
login="pos_user",
13+
groups="point_of_sale.group_pos_user",
2114
)
22-
cls.pos_user_assigned_pos = cls.env["res.users"].create(
23-
{
24-
"login": "pos_user_assigned_pos",
25-
"name": "pos_user_assigned_pos",
26-
"groups_id": [
27-
(
28-
6,
29-
0,
30-
[
31-
cls.env.ref(
32-
"pos_user_restriction.group_assigned_points_of_sale_user"
33-
).id
34-
],
35-
)
36-
],
37-
}
15+
cls.pos_user_assigned_pos = new_test_user(
16+
cls.env,
17+
login="pos_user_assigned_pos",
18+
groups="pos_user_restriction.group_assigned_points_of_sale_user",
3819
)
3920
cls.pos_config_main = cls.env.ref("point_of_sale.pos_config_main")
4021
cls.pos_config_model = cls.env["pos.config"]

0 commit comments

Comments
 (0)