-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtest_integration.py
78 lines (54 loc) · 2.29 KB
/
test_integration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import io
from hdfs_native import Client, WriteOptions
def test_integration(minidfs: str):
client = Client(minidfs)
client.create("/testfile", WriteOptions()).close()
file_info = client.get_file_info("/testfile")
assert file_info.path == "/testfile"
file_list = list(client.list_status("/", False))
assert len(file_list) == 1
assert file_list[0].path == "/testfile"
client.rename("/testfile", "/testfile2", False)
file_list = list(client.list_status("/", False))
assert len(file_list) == 1
assert file_list[0].path == "/testfile2"
client.delete("/testfile2", False)
file_list = list(client.list_status("/", False))
assert len(file_list) == 0
with client.create("/testfile", WriteOptions()) as file:
data = io.BytesIO()
for i in range(0, 32 * 1024 * 1024):
data.write(i.to_bytes(4, 'big'))
file.write(data.getbuffer())
with client.read("/testfile") as file:
data = io.BytesIO(file.read())
for i in range(0, 32 * 1024 * 1024):
assert data.read(4) == i.to_bytes(4, 'big')
with client.append("/testfile") as file:
data = io.BytesIO()
for i in range(32 * 1024 * 1024, 33 * 1024 * 1024):
data.write(i.to_bytes(4, 'big'))
file.write(data.getbuffer())
with client.read("/testfile") as file:
data = io.BytesIO(file.read())
for i in range(0, 33 * 1024 * 1024):
assert data.read(4) == i.to_bytes(4, 'big')
mtime = 1717641455
atime = 1717641456
client.set_times("/testfile", mtime, atime)
file_info = client.get_file_info("/testfile")
assert file_info.modification_time == mtime
assert file_info.access_time == atime
client.set_owner("/testfile", "testuser", "testgroup")
file_info = client.get_file_info("/testfile")
assert file_info.owner == "testuser"
assert file_info.group == "testgroup"
client.set_owner("/testfile", owner="testuser2")
file_info = client.get_file_info("/testfile")
assert file_info.owner == "testuser2"
assert file_info.group == "testgroup"
client.set_owner("/testfile", group="testgroup2")
file_info = client.get_file_info("/testfile")
assert file_info.owner == "testuser2"
assert file_info.group == "testgroup2"
client.delete("/testfile", False)