async def test_async_to_sync_local_file_handler_save(directory): handler = AsyncLocalFileHandler(base_path=directory) handler.save_data(filename='test.txt', data=b'contents') assert exists(directory, 'test.txt') assert get_contents(directory, 'test.txt') == b'contents'
def test_async_only_save(directory): handler = AsyncLocalFileHandler( base_path=directory, allow_sync_methods=False ) with pytest.raises(RuntimeError) as err: handler.save_data(filename='test.txt', data=b'contents') assert str(err.value) == 'Sync save method not allowed'
async def test_async_to_sync_local_file_handler_get_modified_time(directory): handler = AsyncLocalFileHandler(base_path=directory) handler.save_data(filename='test.txt', data=b'contents') assert exists(directory, 'test.txt') item = handler.get_item('test.txt') mtime = handler.get_modified_time('test.txt') assert mtime == datetime.fromtimestamp( os.path.getmtime(handler.local_path(item)) )