コード例 #1
0
def test_rm(azure):
    with azure_teardown(azure):
        assert not azure.exists(a, invalidate_cache=False)
        azure.touch(a)
        assert azure.exists(a, invalidate_cache=False)
        azure.rm(a)
        assert not azure.exists(a, invalidate_cache=False)
コード例 #2
0
def test_rm(azure):
    with azure_teardown(azure):
        assert not azure.exists(a)
        azure.touch(a)
        assert azure.exists(a)
        azure.rm(a)
        assert not azure.exists(a)
コード例 #3
0
def test_copy(azure):
    with azure_teardown(azure):
        azure.touch(a)
        assert azure.exists(a, invalidate_cache=False)
        assert not azure.exists(b, invalidate_cache=False)
        azure.cp(a, b)
        assert azure.exists(a, invalidate_cache=False)
        assert azure.exists(b, invalidate_cache=False)
コード例 #4
0
def test_copy(azure):
    with azure_teardown(azure):
        azure.touch(a)
        assert azure.exists(a)
        assert not azure.exists(b)
        azure.cp(a, b)
        assert azure.exists(a)
        assert azure.exists(b)
コード例 #5
0
def test_move(azure):
    with azure_teardown(azure):
        azure.touch(a)
        assert azure.exists(a)
        assert not azure.exists(b)
        azure.mv(a, b)
        assert not azure.exists(a)
        assert azure.exists(b)
コード例 #6
0
def test_file_creation_open(azure):
    with azure_teardown(azure):
        if azure.exists(a):
            azure.rm(a)
        assert not azure.exists(a)
        f = azure.open(a, "wb")
        assert azure.exists(a)
        f.close()
        assert azure.info(a)['length'] == 0
コード例 #7
0
def test_info_invalidate_cache(azure, second_azure):
    with azure_teardown(azure):
        # construct initial cache and ensure the file doesn't already exist
        assert not azure.exists(a, invalidate_cache=False)
        assert not second_azure.exists(a, invalidate_cache=False)

        with azure.open(a, 'wb') as f:
            f.write(b'a' * 5)

        # verify that it works in the fs that did the write and not on the other
        info = azure.info(a, invalidate_cache=False)
        with pytest.raises(FileNotFoundError):
            second_azure.info(a, invalidate_cache=False)

        # then invalidate
        second_info = second_azure.info(a, invalidate_cache=True)
        assert info['length'] == 5
        assert info['name'] == a
        assert info['type'] == 'FILE'

        assert info['length'] == second_info['length']
        assert info['name'] == second_info['name']
        assert info['type'] == second_info['type']

        # assure that the cache was properly repopulated on the info call
        assert second_azure.info(test_dir,
                                 invalidate_cache=False)['type'] == 'DIRECTORY'
コード例 #8
0
def test_exists_remove_invalidate_cache(azure, second_azure):
    with azure_teardown(azure):
        # test to ensure file does not exist up front, cache doesn't matter
        assert not azure.exists(a, invalidate_cache=False)
        assert not second_azure.exists(a, invalidate_cache=False)
        azure.touch(a)
        # now ensure that it exists in the client that did the work, but not in the other
        assert azure.exists(a, invalidate_cache=False)
        assert not second_azure.exists(a, invalidate_cache=False)
        # now, with cache invalidation it should exist
        assert second_azure.exists(a, invalidate_cache=True)
        azure.rm(a)
        # same idea with remove. It should no longer exist (cache invalidated or not) in client 1, but still exist in client 2
        assert not azure.exists(a, invalidate_cache=False)
        assert second_azure.exists(a, invalidate_cache=False)
        # now ensure it does not exist when we do invalidate the cache
        assert not second_azure.exists(a, invalidate_cache=True)
コード例 #9
0
def setup_tree(azure):
    for directory in ['', 'data/a', 'data/b']:
        azure.mkdir(test_dir / directory)
        for filename in ['x.csv', 'y.csv', 'z.txt']:
            with azure.open(test_dir / directory / filename, 'wb') as f:
                f.write(b'123456')
    try:
        yield
    finally:
        for path in azure.ls(test_dir, invalidate_cache=False):
            if azure.exists(path, invalidate_cache=False):
                azure.rm(path, recursive=True)
コード例 #10
0
def test_upload_overwrite(local_files, azure):
    bigfile, littlefile, emptyfile, a, b, c = local_files

    with azure_teardown(azure):
        # create the folder that we want to make sure the overwrite
        # test fails on if it doesn't already exist
        if not azure.exists(test_dir):
            azure.mkdir(test_dir)

        with pytest.raises(OSError) as e:
            ADLUploader(azure, test_dir, littlefile, nthreads=1)
        assert test_dir.as_posix() in str(e)
コード例 #11
0
def test_touch_exists(azure):
    with azure_teardown(azure):
        azure.touch(a)
        assert azure.exists(a)