({'logger_name': 'fs_local', 'path': valid_path()}, 'fs_local', valid_path()),
({'logger_name': 'fs_local', 'path': valid_path()[:-1]}, 'fs_local', valid_path()),
({'path': valid_path()}, 'fs', valid_path()),
- ({'path': valid_path()[:-1]}, 'fs', valid_path()),
-])
+ ({'path': valid_path()[:-1]}, 'fs', valid_path())])
def test_fs_connect_with_valid_config(config, exp_logger, exp_path):
fs = FsLocal()
fs.fs_connect(config)
({'logger_name': 'fs_local', 'path': invalid_path()}, fs_connect_exception_message(invalid_path())),
({'logger_name': 'fs_local', 'path': invalid_path()[:-1]}, fs_connect_exception_message(invalid_path()[:-1])),
({'path': invalid_path()}, fs_connect_exception_message(invalid_path())),
- ({'path': invalid_path()[:-1]}, fs_connect_exception_message(invalid_path()[:-1])),
-])
+ ({'path': invalid_path()[:-1]}, fs_connect_exception_message(invalid_path()[:-1]))])
def test_fs_connect_with_invalid_path(config, exp_exception_message):
fs = FsLocal()
(str(uuid.uuid4()), 'file', False),
([str(uuid.uuid4())], 'file', False),
(str(uuid.uuid4()), 'dir', False),
- ([str(uuid.uuid4())], 'dir', False),
-])
+ ([str(uuid.uuid4())], 'dir', False)])
def test_file_exists_returns_false(fs_local, storage, mode, expected):
assert fs_local.file_exists(storage, mode) == expected
(str(uuid.uuid4()), 'file', True),
([str(uuid.uuid4())], 'file', True),
(str(uuid.uuid4()), 'dir', True),
- ([str(uuid.uuid4())], 'dir', True),
-])
+ ([str(uuid.uuid4())], 'dir', True)])
def test_file_exists_returns_true(fs_local, storage, mode, expected):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
(str(uuid.uuid4()), 'file'),
([str(uuid.uuid4())], 'file'),
(str(uuid.uuid4()), 'dir'),
- ([str(uuid.uuid4())], 'dir'),
-])
+ ([str(uuid.uuid4())], 'dir')])
def test_file_size(fs_local, storage, mode):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
@pytest.mark.parametrize("files, path", [
(['foo', 'bar', 'foobar'], str(uuid.uuid4())),
- (['foo', 'bar', 'foobar'], [str(uuid.uuid4())]),
-])
+ (['foo', 'bar', 'foobar'], [str(uuid.uuid4())])])
def test_file_extract(fs_local, files, path):
for f in files:
os.mknod(valid_path() + f)
([str(uuid.uuid4())], 'a'),
([str(uuid.uuid4())], 'rb'),
([str(uuid.uuid4())], 'wb'),
- ([str(uuid.uuid4())], 'ab'),
-])
+ ([str(uuid.uuid4())], 'ab')])
def test_file_open(fs_local, storage, mode):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
(str(uuid.uuid4()), 'r'),
(str(uuid.uuid4()), 'rb'),
([str(uuid.uuid4())], 'r'),
- ([str(uuid.uuid4())], 'rb'),
-])
+ ([str(uuid.uuid4())], 'rb')])
def test_file_open_file_not_found_exception(fs_local, storage, mode):
with pytest.raises(FsException) as excinfo:
fs_local.file_open(storage, mode)
([str(uuid.uuid4())], 'a'),
([str(uuid.uuid4())], 'rb'),
([str(uuid.uuid4())], 'wb'),
- ([str(uuid.uuid4())], 'ab'),
-])
+ ([str(uuid.uuid4())], 'ab')])
def test_file_open_io_error(fs_local, storage, mode):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
(str(uuid.uuid4()), True),
(str(uuid.uuid4()), False),
([str(uuid.uuid4())], True),
- ([str(uuid.uuid4())], False),
-])
+ ([str(uuid.uuid4())], False)])
def test_dir_ls(fs_local, storage, with_files):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
@pytest.mark.parametrize("storage", [
(str(uuid.uuid4())),
- ([str(uuid.uuid4())]),
-])
+ ([str(uuid.uuid4())])])
def test_dir_ls_with_not_a_directory_error(fs_local, storage):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
@pytest.mark.parametrize("storage", [
(str(uuid.uuid4())),
- ([str(uuid.uuid4())]),
-])
+ ([str(uuid.uuid4())])])
def test_dir_ls_with_io_error(fs_local, storage):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
([str(uuid.uuid4())], True, True),
([str(uuid.uuid4())], False, True),
([str(uuid.uuid4())], True, False),
- ([str(uuid.uuid4())], False, False),
-])
+ ([str(uuid.uuid4())], False, False)])
def test_file_delete_with_dir(fs_local, storage, with_files, ignore_non_exist):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
@pytest.mark.parametrize("storage", [
(str(uuid.uuid4())),
- ([str(uuid.uuid4())]),
-])
+ ([str(uuid.uuid4())])])
def test_file_delete_expect_exception(fs_local, storage):
with pytest.raises(FsException) as excinfo:
fs_local.file_delete(storage)
@pytest.mark.parametrize("storage", [
(str(uuid.uuid4())),
- ([str(uuid.uuid4())]),
-])
+ ([str(uuid.uuid4())])])
def test_file_delete_no_exception(fs_local, storage):
path = valid_path() + storage if isinstance(storage, str) else valid_path() + storage[0]
fs_local.file_delete(storage, ignore_non_exist=True)
assert os.path.exists(path) == False
-
\ No newline at end of file