How to use the ckanapi.LocalCKAN function in ckanapi

To help you get started, we’ve selected a few ckanapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_group_schema_list(self):
        lc = LocalCKAN('visitor')
        group_schemas = lc.action.scheming_group_schema_list()
        assert_equals(sorted(group_schemas), ['group', 'theme'])
github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_organization_schema_not_found(self):
        lc = LocalCKAN('visitor')
        assert_raises(NotFound,
            lc.action.scheming_organization_schema_show,
            type='elmo')
github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_group_schema_show(self):
        lc = LocalCKAN('visitor')
        schema = lc.action.scheming_group_schema_show(
            type='group')
        assert_equals(schema['fields'][4]['label'], 'Bookface')
github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_group_schema_not_found(self):
        lc = LocalCKAN('visitor')
        assert_raises(NotFound,
            lc.action.scheming_group_schema_show,
            type='bert')
github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_organization_schema_show(self):
        lc = LocalCKAN('visitor')
        schema = lc.action.scheming_organization_schema_show(
            type='organization')
        assert_equals(schema['fields'][4]['label'], 'Department ID')
github ckan / ckanext-scheming / tests / test_group_logic.py View on Github external
def test_organization_schema_list(self):
        lc = LocalCKAN('visitor')
        org_schemas = lc.action.scheming_organization_schema_list()
        assert_equals(sorted(org_schemas), ['organization', 'publisher'])
github ckan / ckanext-scheming / ckanext / scheming / helpers.py View on Github external
"label": "label_column_name" }
    "datastore_choices_limit": 1000 (default)

    When columns aren't specified the first column is used as value
    and second column used as label.
    """
    resource_id = field['datastore_choices_resource']
    limit = field.get('datastore_choices_limit', 1000)
    columns = field.get('datastore_choices_columns')
    fields = None
    if columns:
        fields = [columns['value'], columns['label']]

    # anon user must be able to read choices or this helper
    # could be used to leak data from private datastore tables
    lc = LocalCKAN(username='')
    try:
        result = lc.action.datastore_search(
            resource_id=resource_id,
            limit=limit,
            fields=fields)
    except (NotFound, NotAuthorized):
        return []

    if not fields:
        fields = [f['id'] for f in result['fields'] if f['id'] != '_id']

    return [{'value': r[fields[0]], 'label': r[fields[1]]}
            for r in result['records']]
github TkTech / ckanext-cloudstorage / ckanext / cloudstorage / cli.py View on Github external
def _migrate(args):
    path = args['']
    single_id = args['']
    if not os.path.isdir(path):
        print('The storage directory cannot be found.')
        return

    lc = LocalCKAN()
    resources = {}
    failed = []

    # The resource folder is stuctured like so on disk:
    # - storage/
    #   - ...
    # - resources/
    #   - <3 letter prefix>
    #     - <3 letter prefix>
    #       - 
    #       ...
    #     ...
    #   ...
    for root, dirs, files in os.walk(path):
        # Only the bottom level of the tree actually contains any files. We
        # don't care at all about the overall structure.