Esempio n. 1
0
def test_download_when_file_exists(hello_data):
    """
    Diging a dataset into a location that already has files should fail.
    """
    shovel.bury('test_project', 'test_dataset', 'v0', str(hello_data))
    with pytest.raises(exceptions.FileExists):
        shovel.dig('test_project', 'test_dataset', 'v0', str(hello_data))
Esempio n. 2
0
    def dig():
        parser = argparse.ArgumentParser(
            description='Download a dataset from the default pit',
            usage="shovel dig project dataset version",
        )
        parser.add_argument('local_directory')
        parser.add_argument('project')
        parser.add_argument('dataset')
        parser.add_argument('version')
        args = parser.parse_args(sys.argv[2:])

        shovel.dig(args.local_directory, args.project, args.dataset,
                   args.version)
Esempio n. 3
0
def test_shove_hello(hello_data):
    """
    Bury a "Hello World" text file into the default pit and dig it up again.
    """
    shovel.bury('test_project', 'test_dataset', 'v0', str(hello_data))
    assert len(hello_data.listdir()) == 1

    hello_data.remove()
    assert not hello_data.exists()

    shovel.dig('test_project', 'test_dataset', 'v0', str(hello_data))
    assert hello_data.exists()

    assert hello_data.join('hello.txt').exists()
    assert hello_data.join('hello.txt').read() == 'Hello World'
Esempio n. 4
0
def test_dig_absent_data(hello_data):
    """
    Dig from a newly initialised bucket, wrong project, wrong dataset, wrong version.
    """
    project = 'test_project'
    dataset = 'test_dataset'
    version = 'v0'

    # Bucket just initialised
    with pytest.raises(exceptions.VersionDoesNotExist):
        shovel.dig(project, dataset, version, str(hello_data))
    shovel.bury(project, dataset, version, str(hello_data))
    hello_data.remove()
    shovel.dig(project, dataset, version, str(hello_data))

    # Missing project
    with pytest.raises(exceptions.VersionDoesNotExist):
        shovel.dig(project + '_x', dataset, version, str(hello_data))
    shovel.bury(project + '_x', dataset, version, str(hello_data))
    hello_data.remove()
    shovel.dig(project + '_x', dataset, version, str(hello_data))

    # Missing dataset
    with pytest.raises(exceptions.VersionDoesNotExist):
        shovel.dig(project, dataset + '_x', version, str(hello_data))
    shovel.bury(project, dataset + '_x', version, str(hello_data))
    hello_data.remove()
    shovel.dig(project, dataset + '_x', version, str(hello_data))

    # Missing version
    with pytest.raises(exceptions.VersionDoesNotExist):
        shovel.dig(project, dataset, 'v1', str(hello_data))
    shovel.bury(project, dataset, 'v1', str(hello_data))
    hello_data.remove()
    shovel.dig(project, dataset, 'v1', str(hello_data))