-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
---A basic smb2 test to do session setup tree connect file create, write, read, close
- Loading branch information
Showing
1 changed file
with
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. | ||
from __future__ import absolute_import | ||
|
||
import io | ||
import string | ||
import uuid | ||
|
||
import pytest | ||
|
||
import pike.ntstatus | ||
import pike.smb2 | ||
|
||
|
||
@pytest.fixture | ||
def filename(): | ||
return "test_io_{}.txt".format(uuid.uuid4()) | ||
|
||
|
||
def test_basic_read_write(pike_TreeConnect, filename): | ||
with pike_TreeConnect() as tc: | ||
with tc.chan.create( | ||
tc.tree, | ||
filename, | ||
access=pike.smb2.GENERIC_READ | pike.smb2.GENERIC_WRITE | pike.smb2.DELETE, | ||
options=pike.smb2.FILE_DELETE_ON_CLOSE, | ||
).result() as fh: | ||
buf = "test123" | ||
tc.chan.write(fh, 0, buf) | ||
assert tc.chan.read(fh, len(buf), 0).tobytes().decode() == buf |