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:
Martin Curlej
2018-06-12 10:37:02 +02:00
parent 29130e3da5
commit e2e804b1d6
2 changed files with 26 additions and 0 deletions

View File

@@ -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:

View File

@@ -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)