How to use the datapackage.exceptions.RegistryError function in datapackage

To help you get started, we’ve selected a few datapackage 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 frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_schema_raises_registryerror_if_registry_raised(self,
                                                            registry_mock):
        registry_mock.side_effect = datapackage.exceptions.RegistryError

        with pytest.raises(datapackage.exceptions.RegistryError):
            datapackage.DataPackage()
github frictionlessdata / datapackage-py / tests / test_registry.py View on Github external
def test_init_raises_if_registry_isnt_a_csv():
    url = 'http://some-place.com/registry.txt'
    httpretty.register_uri(httpretty.GET, url, body="foo")
    with pytest.raises(RegistryError):
        datapackage.registry.Registry(url)
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_schema_raises_registryerror_if_registry_raised(registry_mock):
    registry_mock.side_effect = exceptions.RegistryError
    with pytest.raises(exceptions.RegistryError):
        Package()
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_schema_raises_registryerror_if_registry_raised(self,
                                                            registry_mock):
        registry_mock.side_effect = datapackage.exceptions.RegistryError

        with pytest.raises(datapackage.exceptions.RegistryError):
            datapackage.DataPackage()
github frictionlessdata / datapackage-py / tests / test_registry.py View on Github external
"id": "data-package",
        "title": "Data Package",
        "schema": "http://example.com/one.json",
        "schema_path": "inexistent.json",
        "specification": "http://example.com"
      }
    ]
    """
    with tempfile.NamedTemporaryFile(suffix='.csv') as tmpfile:
        tmpfile.write(registry_body.encode('utf-8'))
        tmpfile.flush()

        registry = datapackage.registry.Registry(tmpfile.name)
    profile_url = 'http://example.com/one.json'
    httpretty.register_uri(httpretty.GET, profile_url, status=404)
    with pytest.raises(RegistryError):
        registry.get('data-package')
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_schema_raises_registryerror_if_registry_raised(registry_mock):
    registry_mock.side_effect = exceptions.RegistryError
    with pytest.raises(exceptions.RegistryError):
        Package()
github frictionlessdata / datapackage-py / datapackage / registry.py View on Github external
def __init__(self, registry_path_or_url=DEFAULT_REGISTRY_PATH):
        if os.path.isfile(registry_path_or_url):
            self._BASE_PATH = os.path.dirname(
                os.path.abspath(registry_path_or_url)
            )
        try:
            self._profiles = {}
            self._registry = self._get_registry(registry_path_or_url)
        except (IOError, ValueError) as e:
            six.raise_from(RegistryError(e), e)
github frictionlessdata / datapackage-py / datapackage / registry.py View on Github external
be downloaded from the web. The results are cached, so any subsequent
        calls won't hit the filesystem or the web.

        Args:
            profile_id (str): The ID of the profile you want.

        Raises:
            RegistryError: If there was some problem opening the profile file
                or its format was incorrect.
        '''
        if profile_id not in self._profiles:
            try:
                self._profiles[profile_id] = self._get_profile(profile_id)
            except (ValueError,
                    IOError) as e:
                six.raise_from(RegistryError(e), e)
        return self._profiles[profile_id]