[ckan-changes] commit/ckan: John Glover: [1371] add task_update_many logic layer action

Bitbucket commits-noreply at bitbucket.org
Wed Oct 5 16:34:33 UTC 2011


1 new changeset in ckan:

http://bitbucket.org/okfn/ckan/changeset/f5a29cb34c96/
changeset:   f5a29cb34c96
branch:      feature-1371-task-status-logic-layer
user:        John Glover
date:        2011-10-05 18:33:22
summary:     [1371] add task_update_many logic layer action
affected #:  2 files (-1 bytes)

--- a/ckan/logic/action/update.py	Wed Oct 05 17:02:09 2011 +0100
+++ b/ckan/logic/action/update.py	Wed Oct 05 17:33:22 2011 +0100
@@ -395,8 +395,11 @@
     model.Session.commit()
     return task_status_dictize(task_status, context)
 
-def task_status_update_many(context, data_dicts):
-    return {}
+def task_status_update_many(context, data_dict):
+    results = []
+    for data in data_dict['data']:
+        results.append(task_status_update(context, data))
+    return {'results': results}
 
 ## Modifications for rest api
 


--- a/ckan/tests/functional/api/test_action.py	Wed Oct 05 17:02:09 2011 +0100
+++ b/ckan/tests/functional/api/test_action.py	Wed Oct 05 17:33:22 2011 +0100
@@ -579,7 +579,39 @@
         assert task_status_updated_2 == task_status_updated, task_status_updated_2
 
     def test_21_task_status_update_many(self):
-        pass
+        package_created = self._add_basic_package(u'test_task_status_update_many')
+        task_statuses = {
+            'data': [
+                {
+                    'entity_id': package_created['id'],
+                    'entity_type': u'package',
+                    'task_type': u'test_task',
+                    'key': u'test_task_1',
+                    'value': u'test_value_1',
+                    'state': u'test_state'
+                },
+                {
+                    'entity_id': package_created['id'],
+                    'entity_type': u'package',
+                    'task_type': u'test_task',
+                    'key': u'test_task_2',
+                    'value': u'test_value_2',
+                    'state': u'test_state'
+                }
+            ]
+        }
+        postparams = '%s=1' % json.dumps(task_statuses)
+        res = self.app.post(
+            '/api/action/task_status_update_many', params=postparams,
+            extra_environ={'Authorization': str(self.sysadmin_user.apikey)},
+        )
+        task_statuses_updated = json.loads(res.body)['result']['results']
+        for i in range(len(task_statuses['data'])):
+            task_status = task_statuses['data'][i]
+            task_status_updated = task_statuses_updated[i]
+            task_status_updated.pop('id') 
+            task_status_updated.pop('last_updated') 
+            assert task_status == task_status_updated, (task_status_updated, task_status, i)
 
     def test_22_task_status_normal_user_not_authorized(self):
         task_status = {}

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list