def test_key(loop):
with tempfile.TemporaryDirectory() as d:
config = MergeDict(
name='',
path=d,
executor=None,
)
context = Context({}, loop=loop)
storage = FileSystemStorage(config, context=context, loop=loop)
await storage.init()
assert str(storage.raw_key(('1', '3', ('4',)))).endswith('1/3/4')
assert str(storage.raw_key((PurePath('1'), '3', ('4',)))).endswith('1/3/4')
with pytest.raises(TypeError):
storage.raw_key(1)
with pytest.raises(ValueError):
storage.raw_key('../..')
with pytest.raises(ValueError):
storage.raw_key('/abs/path')
with pytest.raises(ValueError):
storage.raw_key(PurePath('/abs/path'))
评论列表
文章目录