Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] base_user_role : migration to 17.0 #331

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions base_user_role/tests/test_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ def test_role_1_2_with_dates(self):
self.assertEqual(user_group_ids, role_group_ids)

def test_role_unlink(self):
# Get role1 groups
role1_group_ids = (
self.role1_id.implied_ids.ids + self.role1_id.trans_implied_ids.ids
)
role1_group_ids.append(self.role1_id.group_id.id)
role1_group_ids = sorted(set(role1_group_ids))
# Get role1 and role2 groups
role1_groups = self.role1_id.trans_implied_ids | self.role1_id.group_id
role2_groups = self.role2_id.trans_implied_ids | self.role2_id.group_id

# Configure the user with role1 and role2
self.user_id.write(
Expand All @@ -153,22 +150,24 @@ def test_role_unlink(self):
]
}
)
# Check user has groups from role1 and role2
self.assertLessEqual(role1_groups, self.user_id.groups_id)
self.assertLessEqual(role2_groups, self.user_id.groups_id)
# Remove role2
self.role2_id.unlink()
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
self.assertEqual(user_group_ids, role1_group_ids)
# Check user has groups from only role1
self.assertLessEqual(role1_groups, self.user_id.groups_id)
self.assertFalse(role2_groups <= self.user_id.groups_id)
# Remove role1
self.role1_id.unlink()
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
self.assertEqual(user_group_ids, [])
# Check user has no groups from role1 and role2
self.assertFalse(role1_groups <= self.user_id.groups_id)
self.assertFalse(role2_groups <= self.user_id.groups_id)

def test_role_line_unlink(self):
# Get role1 groups
role1_group_ids = (
self.role1_id.implied_ids.ids + self.role1_id.trans_implied_ids.ids
)
role1_group_ids.append(self.role1_id.group_id.id)
role1_group_ids = sorted(set(role1_group_ids))
# Get role1 and role2 groups
role1_groups = self.role1_id.trans_implied_ids | self.role1_id.group_id
role2_groups = self.role2_id.trans_implied_ids | self.role2_id.group_id

# Configure the user with role1 and role2
self.user_id.write(
Expand All @@ -179,18 +178,23 @@ def test_role_line_unlink(self):
]
}
)
# Check user has groups from role1 and role2
self.assertLessEqual(role1_groups, self.user_id.groups_id)
self.assertLessEqual(role2_groups, self.user_id.groups_id)
# Remove role2 from the user
self.user_id.role_line_ids.filtered(
lambda rl: rl.role_id.id == self.role2_id.id
).unlink()
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
self.assertEqual(user_group_ids, role1_group_ids)
# Check user has groups from only role1
self.assertLessEqual(role1_groups, self.user_id.groups_id)
self.assertFalse(role2_groups <= self.user_id.groups_id)
# Remove role1 from the user
self.user_id.role_line_ids.filtered(
lambda rl: rl.role_id.id == self.role1_id.id
).unlink()
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
self.assertEqual(user_group_ids, [])
# Check user has no groups from role1 and role2
self.assertFalse(role1_groups <= self.user_id.groups_id)
self.assertFalse(role2_groups <= self.user_id.groups_id)

def test_default_user_roles(self):
self.default_user.write(
Expand Down
Loading