How to use datapackage - 10 common examples

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_package.py View on Github external
def test_local_with_relative_resources_paths_is_safe():
    package = Package('data/datapackage_with_foo.txt_resource.json', {})
    assert package.safe()
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_init_raises_if_url_isnt_a_json():
    url = 'http://someplace.com/datapackage.json'
    body = 'Not a JSON'
    httpretty.register_uri(httpretty.GET, url, body=body, content_type='application/json')
    with pytest.raises(exceptions.DataPackageException):
        Package(url)
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_base_path_defaults_to_none():
    assert Package().base_path is None
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_init_accepts_dicts():
    descriptor = {
        'profile': 'data-package',
    }
    package = Package(descriptor)
    assert package.descriptor == descriptor
github frictionlessdata / datapackage-py / tests / test_package.py View on Github external
def test_should_raise_if_zipfile_raised_LargeZipFile(zipfile_mock, tmpfile):
    zipfile_mock.side_effect = zipfile.LargeZipFile()
    package = Package({}, {})
    with pytest.raises(exceptions.DataPackageException):
        package.save(tmpfile)
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_generates_filenames_for_named_resources(self, tmpfile):
        descriptor = {
            'name': 'proverbs',
            'resources': [
                {'name': 'proverbs', 'format': 'TXT', 'path': 'unicode.txt'},
                {'name': 'proverbs_without_format', 'path': 'unicode.txt'}
            ]
        }
        schema = {}
        dp = datapackage.DataPackage(
            descriptor, schema, default_base_path='tests/fixtures')
        dp.save(tmpfile)
        with zipfile.ZipFile(tmpfile, 'r') as z:
            assert 'data/proverbs.txt' in z.namelist()
            assert 'data/proverbs_without_format' in z.namelist()
github openknowledge-archive / dpm-py / tests / tests_cli / test_publish_connerror.py View on Github external
def setUp(self):
        # GIVEN datapackage that can be treated as valid by the dpm
        self.valid_dp = datapackage.DataPackage({
                "name": "some-datapackage",
                "resources": [
                    {"name": "some-resource", "path": "./data/some_data.csv", }
                ]
            },
            default_base_path='.')
        patch('dpm.client.DataPackage', lambda *a: self.valid_dp).start()
        patch('dpm.client.exists', lambda *a: True).start()
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_schema(self):
        descriptor = {}
        schema = {'foo': 'bar'}
        dp = datapackage.DataPackage(descriptor, schema=schema)
        assert dp.schema.to_dict() == schema
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_resources_are_empty_tuple_by_default(self):
        descriptor = {}
        dp = datapackage.DataPackage(descriptor)
        assert dp.resources == ()
github frictionlessdata / datapackage-py / tests / test_datapackage.py View on Github external
def test_base_path_cant_be_set_directly(self):
        dp = datapackage.DataPackage()
        with pytest.raises(AttributeError):
            dp.base_path = 'foo'