Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def analyseAPI(url):
#if url == "http://catalog.data.gov/":
# return
print url
try:
package_list, status = util.getPackageList(url)
print "\t",len(package_list),"getPackageList", status
ps_name=[]
ps_id=[]
api = ckanapi.RemoteCKAN(url, get_only=True)
response = api.action.package_search(rows=100000000)
if response:
datasets= response["results"]
for ds in datasets:
ps_name.append(ds['name'])
ps_id.append(ds['id'])
ps_name=set(ps_name)
ps_id=set(ps_id)
print "\t",len(ps_name),len(ps_id),"package_search"
start=0
steps=len(ps_name)
pss_name=[]
pss_id=[]
while True:
def test_remoteckan_validlocations(self, project_config_yaml):
Configuration._create(user_agent='test', hdx_site='prod', hdx_key='TEST_HDX_KEY',
hdx_base_config_dict={}, project_config_yaml=project_config_yaml)
remoteckan = ckanapi.RemoteCKAN('http://lalala', apikey='12345',
user_agent='HDXPythonLibrary/1.0')
Configuration.read().setup_remoteckan(remoteckan=remoteckan)
assert Configuration.read().remoteckan() == remoteckan
remoteckan = ckanapi.RemoteCKAN('http://hahaha', apikey='54321',
user_agent='HDXPythonLibrary/0.5')
Configuration._create(user_agent='test',
remoteckan=remoteckan,
hdx_site='prod', hdx_key='TEST_HDX_KEY',
hdx_base_config_dict={},
project_config_yaml=project_config_yaml)
assert Configuration.read().remoteckan() == remoteckan
Configuration.read()._remoteckan = None
with pytest.raises(ConfigurationError):
Configuration.read().remoteckan()
Configuration.delete()
with pytest.raises(ConfigurationError):
Configuration.read().remoteckan()
:param action: the action name, e.g. 'package_create'
:param data_dict: the dict to pass to the action as JSON,
defaults to {}
:param context: not supported
:param files: not supported
This function parses the response from the server as JSON and
returns the decoded value. When an error is returned this
function will convert it back to an exception that matches the
one the action function itself raised.
"""
if context:
raise CKANAPIError("TestAppCKAN.call_action does not support "
"use of context parameter, use apikey instead")
if files:
raise CKANAPIError("TestAppCKAN.call_action does not support "
"file uploads, consider contributing it if you need it")
url, data, headers = prepare_action(action, data_dict,
apikey or self.apikey)
r = self.test_app.post('/' + url, data, headers, expect_errors=True)
return reverse_apicontroller_action(url, r.status, r.body)
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'])
def test_organization_schema_not_found(self):
lc = LocalCKAN('visitor')
assert_raises(NotFound,
lc.action.scheming_organization_schema_show,
type='elmo')