Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-FAIR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
nomad-FAIR
Commits
373ada3e
Commit
373ada3e
authored
9 months ago
by
Sascha Klawohn
Browse files
Options
Downloads
Patches
Plain Diff
Test: multi ID, search_terms /groups filters
parent
89e14086
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1979
Get groups filters
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/app/v1/routers/test_groups.py
+42
-0
42 additions, 0 deletions
tests/app/v1/routers/test_groups.py
tests/fixtures/groups.py
+8
-2
8 additions, 2 deletions
tests/fixtures/groups.py
with
50 additions
and
2 deletions
tests/app/v1/routers/test_groups.py
+
42
−
0
View file @
373ada3e
...
@@ -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
'
,
[
[
...
...
This diff is collapsed.
Click to expand it.
tests/fixtures/groups.py
+
8
−
2
View file @
373ada3e
...
@@ -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
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment