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_invalid(self):
self.assertRaises(
ckanapi.ValidationError,
self.ckan.action.invalid)
def test_data(self):
force_restricted (bool, optional): if True, then export restricted bundles as private (for debugging
purposes).
Raises:
EnvironmentError: if ckan credentials are missing or invalid.
UnpublishedAccessError: if dataset has unpublished access - one from ('internal', 'test',
'controlled', 'restricted', 'census').
"""
if not ckan:
raise EnvironmentError(MISSING_CREDENTIALS_MSG)
# publish dataset.
try:
ckan.action.package_create(**_convert_bundle(bundle))
except ckanapi.ValidationError:
if force:
logger.warning(
'{} dataset already exported, but new export forced. Continue to export dataset stuff.'
.format(bundle.dataset))
else:
raise
# set permissions.
access = bundle.dataset.config.metadata.about.access
if access == 'restricted' and force_restricted:
access = 'private'
assert access, 'CKAN publishing requires access level.'
if access in ('internal', 'controlled', 'restricted', 'census'):