-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindings/python): Support
exists
API for python binding
Co-authored-by: Zheao Li <me@manjusaka.me> Signed-off-by: Manjusaka <me@manjusaka.me> Signed-off-by: Yashika soni <soniyashika164@gmail.com>
- Loading branch information
1 parent
260fcd4
commit c6e9a9f
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
from random import randint | ||
from uuid import uuid4 | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.need_capability("write", "delete", "stat") | ||
def test_sync_exists(service_name, operator, async_operator): | ||
size = randint(1, 1024) | ||
filename = f"test_file_{str(uuid4())}.txt" | ||
content = os.urandom(size) | ||
size = len(content) | ||
operator.write(filename, content) | ||
assert operator.exists(filename) | ||
assert not operator.exists(filename + "not_exists") | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.need_capability("write", "delete", "stat") | ||
async def test_async_exists(service_name, operator, async_operator): | ||
size = randint(1, 1024) | ||
filename = f"test_file_{str(uuid4())}.txt" | ||
content = os.urandom(size) | ||
size = len(content) | ||
await async_operator.write(filename, content) | ||
assert await async_operator.exists(filename) | ||
assert not await async_operator.exists(filename + "not_exists") | ||
await async_operator.delete(filename) |