[ckan-changes] commit/ckan: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Fri Aug 5 14:39:18 UTC 2011


2 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/188d27a56c89/
changeset:   188d27a56c89
branch:      release-v1.4.3
user:        dread
date:        2011-08-05 16:38:00
summary:     [logic]: Fix exception showing tag when the license is a value not in the list of license ids. This bug is believed to be only in 1.4.3beta.
affected #:  2 files (868 bytes)

--- a/ckan/logic/action/get.py	Fri Aug 05 12:00:27 2011 +0100
+++ b/ckan/logic/action/get.py	Fri Aug 05 15:38:00 2011 +0100
@@ -531,7 +531,10 @@
         package_dict['resources'] = []
     license_id = package_dict['license_id']
     if license_id:
-        isopen = model.Package.get_license_register()[license_id].isopen()
+        try:
+            isopen = model.Package.get_license_register()[license_id].isopen()
+        except KeyError:
+            isopen = False
         package_dict['isopen'] = isopen
     else:
         package_dict['isopen'] = False


--- a/ckan/tests/functional/api/test_action.py	Fri Aug 05 12:00:27 2011 +0100
+++ b/ckan/tests/functional/api/test_action.py	Fri Aug 05 15:38:00 2011 +0100
@@ -184,6 +184,26 @@
         assert 'packages' in result and len(result['packages']) == 3
         assert [package['name'] for package in result['packages']].sort() == ['annakarenina', 'warandpeace', 'moo'].sort()
 
+    def test_07_tag_show_unknown_license(self):
+        # create a tagged package which has an invalid license
+        CreateTestData.create_arbitrary([{
+            'name': u'tag_test',
+            'tags': u'tolstoy',
+            'license': 'never_heard_of_it',
+            }])
+        postparams = '%s=1' % json.dumps({'id':'tolstoy'})
+        res = self.app.post('/api/action/tag_show', params=postparams)
+        res_obj = json.loads(res.body)
+        assert res_obj['success'] == True
+        result = res_obj['result']
+        for pkg in result['packages']:
+            if pkg['name'] == 'tag_test':
+                break
+        else:
+            assert 0, 'tag_test not among packages'
+        assert_equal(pkg['license_id'], 'never_heard_of_it')
+        assert_equal(pkg['isopen'], False)
+
     def test_08_user_create_not_authorized(self):
         postparams = '%s=1' % json.dumps({'name':'test_create_from_action_api', 'password':'testpass'})
         res = self.app.post('/api/action/user_create', params=postparams,


http://bitbucket.org/okfn/ckan/changeset/392786cdcbed/
changeset:   392786cdcbed
user:        dread
date:        2011-08-05 16:39:03
summary:     [merge] from release-v1.4.3.
affected #:  2 files (868 bytes)

--- a/ckan/logic/action/get.py	Fri Aug 05 12:05:39 2011 +0100
+++ b/ckan/logic/action/get.py	Fri Aug 05 15:39:03 2011 +0100
@@ -557,7 +557,10 @@
         package_dict['resources'] = []
     license_id = package_dict['license_id']
     if license_id:
-        isopen = model.Package.get_license_register()[license_id].isopen()
+        try:
+            isopen = model.Package.get_license_register()[license_id].isopen()
+        except KeyError:
+            isopen = False
         package_dict['isopen'] = isopen
     else:
         package_dict['isopen'] = False


--- a/ckan/tests/functional/api/test_action.py	Fri Aug 05 12:05:39 2011 +0100
+++ b/ckan/tests/functional/api/test_action.py	Fri Aug 05 15:39:03 2011 +0100
@@ -184,6 +184,26 @@
         assert 'packages' in result and len(result['packages']) == 3
         assert [package['name'] for package in result['packages']].sort() == ['annakarenina', 'warandpeace', 'moo'].sort()
 
+    def test_07_tag_show_unknown_license(self):
+        # create a tagged package which has an invalid license
+        CreateTestData.create_arbitrary([{
+            'name': u'tag_test',
+            'tags': u'tolstoy',
+            'license': 'never_heard_of_it',
+            }])
+        postparams = '%s=1' % json.dumps({'id':'tolstoy'})
+        res = self.app.post('/api/action/tag_show', params=postparams)
+        res_obj = json.loads(res.body)
+        assert res_obj['success'] == True
+        result = res_obj['result']
+        for pkg in result['packages']:
+            if pkg['name'] == 'tag_test':
+                break
+        else:
+            assert 0, 'tag_test not among packages'
+        assert_equal(pkg['license_id'], 'never_heard_of_it')
+        assert_equal(pkg['isopen'], False)
+
     def test_08_user_create_not_authorized(self):
         postparams = '%s=1' % json.dumps({'name':'test_create_from_action_api', 'password':'testpass'})
         res = self.app.post('/api/action/user_create', params=postparams,

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