Skip to content
Snippets Groups Projects
Commit 373ada3e authored by Sascha Klawohn's avatar Sascha Klawohn
Browse files

Test: multi ID, search_terms /groups filters

parent 89e14086
No related branches found
No related tags found
1 merge request!1979Get groups filters
...@@ -58,6 +58,48 @@ def test_get_groups( ...@@ -58,6 +58,48 @@ def test_get_groups(
assert_group(group, response_group) assert_group(group, response_group)
@pytest.mark.parametrize(
'filters, ref_group_labels',
[
pytest.param({'group_id': ['group1']}, ['group1'], id='id'),
pytest.param(
{'group_id': ['group1', 'group2']}, ['group1', 'group2'], id='ids'
),
pytest.param({'search_terms': ['Uniq']}, ['uniq'], id='uniq'),
pytest.param({'search_terms': ['iq']}, ['uniq'], id='uniq-partial'),
pytest.param({'search_terms': ['Twin']}, ['twin1', 'twin2'], id='twins'),
pytest.param({'search_terms': ['Twin One']}, ['twin1'], id='twin1'),
pytest.param(
{'search_terms': ['One']}, ['twin1', 'numerals'], id='twin1-numerals'
),
pytest.param({'search_terms': ['One Two']}, ['numerals'], id='numerals'),
pytest.param(
{'search_terms': ['Tw']}, ['twin1', 'twin2', 'numerals'], id='tw-partial'
),
],
)
def test_get_filtered_groups(
auth_headers,
client,
convert_group_labels_to_ids,
groups_module,
filters,
ref_group_labels,
):
filters = convert_group_labels_to_ids(filters)
response = perform_get(client, base_url, auth_headers['user1'], **filters)
assert_response(response, 200)
response_groups = UserGroups.parse_raw(response.content)
response_ids = [group.group_id for group in response_groups.data]
ref_group_ids = convert_group_labels_to_ids(ref_group_labels)
assert_unordered_lists(response_ids, ref_group_ids)
for response_group in response_groups.data:
group = get_user_group(response_group.group_id)
assert_group(group, response_group)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'user_label, expected_status_code', 'user_label, expected_status_code',
[ [
......
...@@ -15,8 +15,10 @@ from tests.utils import fake_group_uuid, fake_user_uuid, generate_convert_label ...@@ -15,8 +15,10 @@ from tests.utils import fake_group_uuid, fake_user_uuid, generate_convert_label
def group_molds(): def group_molds():
"""Return a dict: group label -> group data (dict).""" """Return a dict: group label -> group data (dict)."""
def old_group(owner, members): def old_group(owner, members, group_str=None):
group_str = str(owner) + ''.join(str(m) for m in members) if group_str is None:
group_str = str(owner) + ''.join(str(m) for m in members)
return dict( return dict(
group_id=fake_group_uuid(group_str), group_id=fake_group_uuid(group_str),
group_name=f'Group {group_str}', group_name=f'Group {group_str}',
...@@ -43,6 +45,10 @@ def group_molds(): ...@@ -43,6 +45,10 @@ def group_molds():
'group18': old_group(1, [8]), 'group18': old_group(1, [8]),
'group19': old_group(1, [9]), 'group19': old_group(1, [9]),
'group123': old_group(1, [2, 3]), 'group123': old_group(1, [2, 3]),
'uniq': old_group(0, [], 'Uniq'),
'twin1': old_group(0, [], 'Twin One'),
'twin2': old_group(0, [], 'Twin Two'),
'numerals': old_group(0, [], 'One Two Three'),
} }
new_groups = { new_groups = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment