def test_delete(self, api, imp): ''' Test deleting a package. ''' pkg_dict = factories.Dataset() pkg = Package('1', pkg_dict, imp) pkg._delete() # Make sure that the package wasn't just moved to the trash but # completely purged by creating a package with the same name. api.action.package_create(name=pkg_dict['name'])
def test_upload(self, api, imp): ''' Test uploading a package. ''' pkg_dict = factories.Dataset() pkg = Package('1', pkg_dict, imp) title = 'A new title' pkg['title'] = title pkg._upload() assert pkg_dict == api.action.package_show(id=pkg_dict['id']) assert pkg_dict['title'] == title
def test_delete(self, api, imp): res_dict = factories.Resource() pkg_dict = api.action.package_show(id=res_dict['package_id']) pkg = Package('1', pkg_dict, imp) res = Resource('1', res_dict, pkg) res._delete() with pytest.raises(ckan.logic.NotFound): api.action.resource_show(id=res_dict['id'])
def test_delete_when_not_existing(self, api, imp): ''' Test deleting a view when it doesn't already exist. ''' res_dict = factories.Resource() pkg_dict = api.action.package_show(id=res_dict['package_id']) pkg = Package('1', pkg_dict, imp) res = Resource('1', res_dict, pkg) view_dict = {'title': 'A title', 'view_type': 'image_view'} view = View('1', view_dict, res) view._delete()
def test_upload(self, api, imp): ''' Test uploading a resource. ''' res_dict = factories.Resource() pkg_dict = api.action.package_show(id=res_dict['package_id']) pkg = Package('1', pkg_dict, imp) res = Resource('1', res_dict, pkg) name = 'A new name' res['name'] = name res._upload() assert res_dict == api.action.resource_show(id=res_dict['id']) assert res_dict['name'] == name
def test_delete_when_existing(self, api, imp): ''' Test deleting an existing view. ''' res_dict = factories.Resource() pkg_dict = api.action.package_show(id=res_dict['package_id']) pkg = Package('1', pkg_dict, imp) res = Resource('1', res_dict, pkg) view_dict = {'title': 'A title', 'view_type': 'image_view'} view = View('1', view_dict, res) view._upload() view._delete() with pytest.raises(ckan.logic.NotFound): api.action.resource_view_show(id=view_dict['id'])
def test_upload_when_existing(self, api, imp): ''' Test uploading an existing view. ''' view_dict = factories.ResourceView() res_dict = api.action.resource_show(id=view_dict['resource_id']) pkg_dict = api.action.package_show(id=res_dict['package_id']) pkg = Package('1', pkg_dict, imp) res = Resource('1', res_dict, pkg) view = View('1', view_dict, res) title = 'A new title' view['title'] = title view._upload() assert view_dict == api.action.resource_view_show(id=view_dict['id']) assert view_dict['title'] == title