Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
---------------------------------------------------------------
commit b2e5368aa9a9036711948ce290fbf94d6ac43cdc
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 16:13:35 2012 +0100
The update_builds url is now returning information about builds that weren't found
while updating (if any)
---------------------------------------------------------------
.../coprs/views/backend_ns/backend_general.py | 4 +++-
.../test_views/test_backend_ns/test_general.py | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/coprs/views/backend_ns/backend_general.py
b/coprs_frontend/coprs/views/backend_ns/backend_general.py
index ec56972..1755e79 100644
--- a/coprs_frontend/coprs/views/backend_ns/backend_general.py
+++ b/coprs_frontend/coprs/views/backend_ns/backend_general.py
@@ -32,9 +32,11 @@ def update_builds():
for build in builds_logic.BuildsLogic.get_by_ids(None, build_ids).all():
existing[build.id] = build
+ non_existing_ids = list(set(build_ids) - set(existing.keys()))
+
for build in flask.request.json['builds']: # actually update existing builds
builds_logic.BuildsLogic.update_state_from_dict(None,
existing[build['id']], build)
db.session.commit()
- return flask.json.dumps({'updated_builds': len(existing)})
+ return flask.json.dumps({'updated_builds_ids': list(existing.keys()),
'non_existing_builds_ids': non_existing_ids})
diff --git a/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
b/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
index 3a5d49e..5f3eaa3 100644
--- a/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
@@ -36,4 +36,5 @@ class TestUpdateBuilds(CoprsTestCase):
content_type='application/json',
headers = self.auth_header,
data = data)
- assert r.data == '{"updated_builds": 1}'
+ assert json.loads(r.data)["updated_builds_ids"] == [1]
+ assert json.loads(r.data)["non_existing_builds_ids"] == []