Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_group_schema_list(self):
lc = LocalCKAN('visitor')
group_schemas = lc.action.scheming_group_schema_list()
assert_equals(sorted(group_schemas), ['group', 'theme'])
def test_organization_schema_not_found(self):
lc = LocalCKAN('visitor')
assert_raises(NotFound,
lc.action.scheming_organization_schema_show,
type='elmo')
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')
def test_group_schema_not_found(self):
lc = LocalCKAN('visitor')
assert_raises(NotFound,
lc.action.scheming_group_schema_show,
type='bert')
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')
def test_organization_schema_list(self):
lc = LocalCKAN('visitor')
org_schemas = lc.action.scheming_organization_schema_list()
assert_equals(sorted(org_schemas), ['organization', 'publisher'])
"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']]
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.