tests: handle varying displayed role fields row order (#64305)

This commit is contained in:
Paul Marillonnet 2022-04-25 14:40:00 +02:00
parent b0132b0a15
commit 43fe2fc307
1 changed files with 12 additions and 11 deletions

View File

@ -168,8 +168,9 @@ def test_manager_role_import(app, admin, ou1, role_ou1, ou2, role_ou2):
export_response = response.click('Export')
new_export = export_response.json
assert len(export['roles']) == 2
assert new_export['roles'][0]['uuid'] == export['roles'][0]['uuid']
assert new_export['roles'][1]['uuid'] == export['roles'][1]['uuid']
uuids = {role['uuid'] for role in export['roles']}
new_uuids = {role['uuid'] for role in new_export['roles']}
assert uuids == new_uuids
# import in custom OU while roles exist in another OU
resp = app.get('/manage/roles/')
@ -268,33 +269,33 @@ def test_roles_displayed_fields(app, admin, ou1, ou2):
# check OUTable
response = app.get('/manage/roles/')
rows = list(
rows = set(
zip(
[text_content(el) for el in response.pyquery('tr td.name')],
[text_content(el) for el in response.pyquery('tr td.member_count')],
)
)
assert rows == [
assert rows == {
('role1', '2'),
('role2 (LDAP)', '0'),
]
}
# check UserRolesTable
response = app.get('/manage/users/%s/roles/?search-ou=all' % user2.pk)
rows = list(
rows = set(
zip(
[text_content(el) for el in response.pyquery('tr td.name')],
[text_content(el) for el in response.pyquery('tr td.via')],
)
)
assert rows == [
assert rows == {
('role1', ''),
('role2 (LDAP)', 'role1 '),
]
}
# check OuUserRolesTable
response = app.get('/manage/users/%s/roles/?search-ou=' % user2.pk)
rows = list(
rows = set(
zip(
[text_content(el) for el in response.pyquery('tr td.name')],
[text_content(el) for el in response.pyquery('tr td.via')],
@ -302,10 +303,10 @@ def test_roles_displayed_fields(app, admin, ou1, ou2):
[el.attrib.get('disabled') for el in response.pyquery('tr td.member input')],
)
)
assert rows == [
assert rows == {
('role1', '', 'checked', None),
('role2 (LDAP)', 'role1 ', None, 'disabled'),
]
}
def test_manager_role_csv_import(app, admin, ou1, ou2):