mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-14 00:29:57 +08:00
Return empty result if short=true is specified on empty list of builds
Fixes #1376 Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
@@ -125,7 +125,7 @@ class AbstractQueryableBuildAPI(MethodView):
|
||||
json_func_kwargs["show_state_url"] = True
|
||||
json_func_kwargs["api_version"] = api_version
|
||||
elif short_flag == "true" or short_flag == "1":
|
||||
if hasattr(p_query.items[0], "short_json"):
|
||||
if p_query.items and hasattr(p_query.items[0], "short_json"):
|
||||
json_func_name = "short_json"
|
||||
if json_func_name == "json" or json_func_name == "extended_json":
|
||||
# Only ModuleBuild.json and ModuleBuild.extended_json has argument db_session
|
||||
|
||||
@@ -524,6 +524,12 @@ class TestViews:
|
||||
assert rv.status_code == 400
|
||||
assert results == expected_error
|
||||
|
||||
def test_query_builds_get_short_json_from_empty_list_of_builds(self):
|
||||
rv = self.client.get("/module-build-service/1/module-builds/?name=pkgname&short=true")
|
||||
data = json.loads(rv.data)
|
||||
assert [] == data["items"]
|
||||
assert 0 == data["meta"]["total"]
|
||||
|
||||
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