mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 16:59:52 +08:00
Added the ability to search mbs builds by the whole NSVC string.
Signed-off-by: Martin Curlej <mcurlej@redhat.com> Found about the magical properties of zip. Signed-off-by: Martin Curlej <mcurlej@redhat.com>
This commit is contained in:
@@ -196,6 +196,13 @@ def filter_module_builds(flask_request):
|
||||
else:
|
||||
raise ValidationError('An invalid state was supplied')
|
||||
|
||||
nsvc = flask_request.args.get('nsvc', None)
|
||||
if nsvc:
|
||||
nsvc_parts = nsvc.split(":")
|
||||
query_keys = ["name", "stream", "version", "context"]
|
||||
for key, part in zip(query_keys, nsvc_parts):
|
||||
search_query[key] = part
|
||||
|
||||
query = models.ModuleBuild.query
|
||||
|
||||
if search_query:
|
||||
|
||||
@@ -373,6 +373,25 @@ class TestViews:
|
||||
}
|
||||
assert actual == expected
|
||||
|
||||
def test_query_builds_with_nsvc(self):
|
||||
nsvcs = ["testmodule:4.3.43:7:00000000",
|
||||
"testmodule:4.3.43:7",
|
||||
"testmodule:4.3.43",
|
||||
"testmodule"]
|
||||
|
||||
results = []
|
||||
for nsvc in nsvcs:
|
||||
rv = self.client.get('/module-build-service/1/module-builds/?nsvc=%s&per_page=2' % nsvc)
|
||||
results.append(json.loads(rv.data)['items'])
|
||||
|
||||
nsvc_keys = ["name", "stream", "version", "context"]
|
||||
|
||||
for items, nsvc in zip(results, nsvcs):
|
||||
nsvc_parts = nsvc.split(":")
|
||||
for item in items:
|
||||
for key, part in zip(nsvc_keys, nsvc_parts):
|
||||
assert item[key] == part
|
||||
|
||||
def test_query_component_build(self):
|
||||
rv = self.client.get('/module-build-service/1/component-builds/1')
|
||||
data = json.loads(rv.data)
|
||||
|
||||
Reference in New Issue
Block a user