Skip to content

Commit

Permalink
[#953] Fix a broken test
Browse files Browse the repository at this point in the history
This test was trying to create private datasets that don't belong to any
organization, which isn't allowed.
  • Loading branch information
Sean Hammond committed Jun 26, 2013
1 parent 972b1c8 commit 2ebad5b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ckan/tests/logic/test_action.py
Expand Up @@ -10,6 +10,7 @@
from ckan.lib.create_test_data import CreateTestData
from ckan.lib.dictization.model_dictize import resource_dictize
import ckan.model as model
import ckan.tests as tests
from ckan.tests import WsgiAppCase
from ckan.tests.functional.api import assert_dicts_equal_ignoring_ordering
from ckan.tests import setup_test_search_index, search_related
Expand Down Expand Up @@ -181,12 +182,10 @@ def test_03_create_update_package(self):

def test_03_create_private_package(self):

def _do_request(package_dict):
postparams = '%s=1' % json.dumps(package_dict)
res = self.app.post('/api/action/package_create', params=postparams,
extra_environ={'Authorization': str(self.sysadmin_user.apikey)})
package_created = json.loads(res.body)['result']
return package_created
# Make an organization, because private datasets must belong to one.
organization = tests.call_action_api(self.app, 'organization_create',
name='test_org',
apikey=self.sysadmin_user.apikey)

# Create a dataset without specifying visibility
package_dict = {
Expand All @@ -212,24 +211,32 @@ def _do_request(package_dict):
'tags': [{'name': u'russian'}, {'name': u'tolstoy'}],
'title': u'A Novel By Tolstoy',
'url': u'http://www.annakarenina.com',
'owner_org': organization['id'],
'version': u'0.7a',
}

package_created = _do_request(package_dict)
package_created = tests.call_action_api(self.app, 'package_create',
apikey=self.sysadmin_user.apikey,
**package_dict)
assert package_created['private'] is False

# Create a new one, explicitly saying it is public
package_dict['name'] = u'annakareninanew_vis_public'
package_dict['private'] = False

package_created_public = _do_request(package_dict)
package_created_public = tests.call_action_api(self.app,
'package_create',
apikey=self.sysadmin_user.apikey,
**package_dict)
assert package_created_public['private'] is False

# Create a new one, explicitly saying it is private
package_dict['name'] = u'annakareninanew_vis_private'
package_dict['private'] = True

package_created_private = _do_request(package_dict)
package_created_private = tests.call_action_api(self.app,
'package_create',
apikey=self.sysadmin_user.apikey,
**package_dict)
assert package_created_private['private'] is True


Expand Down

0 comments on commit 2ebad5b

Please sign in to comment.