How to use the ckanapi.ValidationError 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 / ckanapi / tests / test_testapp.py View on Github external
def test_invalid(self):
        self.assertRaises(
            ckanapi.ValidationError,
            self.ckan.action.invalid)
    def test_data(self):
github CivicSpleen / ambry / ambry / exporters / ckan / core.py View on Github external
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'):