[ckan-changes] commit/ckan: John Glover: [1371] slight refactor of task_status logic layer tests

Bitbucket commits-noreply at bitbucket.org
Wed Oct 5 16:02:31 UTC 2011


1 new changeset in ckan:

http://bitbucket.org/okfn/ckan/changeset/5f5a1799dd80/
changeset:   5f5a1799dd80
branch:      feature-1371-task-status-logic-layer
user:        John Glover
date:        2011-10-05 18:02:09
summary:     [1371] slight refactor of task_status logic layer tests
affected #:  1 file (-1 bytes)

--- a/ckan/tests/functional/api/test_action.py	Wed Oct 05 16:48:59 2011 +0100
+++ b/ckan/tests/functional/api/test_action.py	Wed Oct 05 17:02:09 2011 +0100
@@ -30,6 +30,22 @@
     def teardown_class(self):
         model.repo.rebuild_db()
 
+    def _add_basic_package(self, package_name=u'test_package'):
+        package = {
+            'name': package_name,
+            'title': u'A Novel By Tolstoy',
+            'resources': [{
+                'description': u'Full text.',
+                'format': u'plain text',
+                'url': u'http://www.annakarenina.com/download/'
+            }]
+        }
+
+        postparams = '%s=1' % json.dumps(package)
+        res = self.app.post('/api/action/package_create', params=postparams,
+                            extra_environ={'Authorization': 'tester'})
+        return json.loads(res.body)['result']
+
     def test_01_package_list(self):
         postparams = '%s=1' % json.dumps({})
         res = self.app.post('/api/action/package_list', params=postparams)
@@ -531,20 +547,7 @@
         assert resource_updated == resource_created
 
     def test_20_task_status_update(self):
-        package = {
-            'name': u'test_task_status_update',
-            'title': u'A Novel By Tolstoy',
-            'resources': [{
-                'description': u'Full text.',
-                'format': u'plain text',
-                'url': u'http://www.annakarenina.com/download/'
-            }]
-        }
-
-        postparams = '%s=1' % json.dumps(package)
-        res = self.app.post('/api/action/package_create', params=postparams,
-                            extra_environ={'Authorization': 'tester'})
-        package_created = json.loads(res.body)['result']
+        package_created = self._add_basic_package(u'test_task_status_update')
 
         task_status = {
             'entity_id': package_created['id'],
@@ -604,20 +607,7 @@
         )
 
     def test_24_task_status_show(self):
-        package = {
-            'name': u'test_task_status_show',
-            'title': u'A Novel By Tolstoy',
-            'resources': [{
-                'description': u'Full text.',
-                'format': u'plain text',
-                'url': u'http://www.annakarenina.com/download/'
-            }]
-        }
-
-        postparams = '%s=1' % json.dumps(package)
-        res = self.app.post('/api/action/package_create', params=postparams,
-                            extra_environ={'Authorization': 'tester'})
-        package_created = json.loads(res.body)['result']
+        package_created = self._add_basic_package(u'test_task_status_show')
 
         task_status = {
             'entity_id': package_created['id'],
@@ -646,20 +636,7 @@
         assert task_status_show == task_status_updated, (task_status_show, task_status_updated)
 
     def test_25_task_status_delete(self):
-        package = {
-            'name': u'test_task_status_delete',
-            'title': u'A Novel By Tolstoy',
-            'resources': [{
-                'description': u'Full text.',
-                'format': u'plain text',
-                'url': u'http://www.annakarenina.com/download/'
-            }]
-        }
-
-        postparams = '%s=1' % json.dumps(package)
-        res = self.app.post('/api/action/package_create', params=postparams,
-                            extra_environ={'Authorization': 'tester'})
-        package_created = json.loads(res.body)['result']
+        package_created = self._add_basic_package(u'test_task_status_delete')
 
         task_status = {
             'entity_id': package_created['id'],

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