We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is an example I already use
import ckanapi import pprint import datetime API_KEY = "xxxxxxxxxxxxxxxxxxxx" # some non-sysadmin's API token demo = ckanapi.RemoteCKAN('http://myserver.myorg.local', apikey=API_KEY) res = demo.action.package_list() pprint.pprint(res) res = demo.action.organization_list_for_user() pprint.pprint(res) TESTPKG_NAME = f"publicrestrictiondatasets_test{datetime.date.today().strftime('%Y%m%d')}" TESTPKG_ORG = "xxxxxxxxxx-b9fb-4c77-8bbe-xxxxxxxxxx" # attempt to create public dataset print("\n==========\ntest creating public pkg\n==========") try: res = demo.action.package_create(**{ "name": TESTPKG_NAME, "private": False, "owner_org": TESTPKG_ORG }) # pprint.pprint(res) except Exception as e: pprint.pprint(e) errd = e.error_dict assert 'private' in errd assert errd['private'][0] == 'Only sysadmin users may set datasets as public' print("SUCCESS\n\n") # attempt to create private dataset print("\n==========\ntest creating private pkg\n==========") res = demo.action.package_create(**{ "name": TESTPKG_NAME, "private": True, "owner_org": TESTPKG_ORG }) # pprint.pprint(res) print("SUCCESS\n\n") # attempt to convert private dataset public print("\n==========\ntest convert private to public pkg\n==========") try: res = demo.action.package_update(**{ "name": TESTPKG_NAME, "private": False, }) # pprint.pprint(res) except Exception as e: pprint.pprint(e.error_dict) errd = e.error_dict assert 'private' in errd assert errd['private'][0] == 'Only sysadmin users may set datasets as public' print("SUCCESS\n\n") # attempt to modify an existing public dataset in any other way print("\n==========\ntest modify existing public pkg\n==========") res = demo.action.package_update(**{ "name": "another-public-test-dataset", "author": TESTPKG_NAME, }) # pprint.pprint(res) print("SUCCESS\n\n") # delete dataset create for testing here print("\n==========\n deleting test pkg\n==========") res = demo.action.package_delete(**{ "id": TESTPKG_NAME }) pprint.pprint(res)
The text was updated successfully, but these errors were encountered:
see https://docs.ckan.org/en/2.9/extensions/testing-extensions.html
Sorry, something went wrong.
No branches or pull requests
Here is an example I already use
The text was updated successfully, but these errors were encountered: