-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_oss.py
46 lines (37 loc) · 1.18 KB
/
test_oss.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
from django.conf import settings
__author__ = 'lfyzjck'
host = 'oss.aliyuncs.com'
access_key = ''
secret_key = ''
bucket = 'lfyzjck-test'
# configure django settings
settings.configure()
from aliyun_oss_storage.oss_storage import AliyunOssStorage
def test_init():
s = AliyunOssStorage(host='xx', bucket='x', access_key=access_key, secret_key=secret_key)
assert s.host == 'xx'
assert s.bucket == 'x'
assert s.connection is not None
def test_put_file():
s = AliyunOssStorage(host, bucket, access_key, secret_key)
assert s._put_file('folder/test.txt', "test content")
assert s.delete('folder/test.txt')
def test_delete_file():
f = 'xx.txt'
s = AliyunOssStorage(host, bucket, access_key, secret_key)
assert s._save(f, "test content")
assert s.delete(f)
def test_exists():
f = 'xxx.txt'
s = AliyunOssStorage(host, bucket, access_key, secret_key)
assert s.exists(f)==False
assert s._save(f, "ss")
assert s.exists(f)
assert s.delete(f)
def test_get_size():
f = 'xxx.txt'
s = AliyunOssStorage(host, bucket, access_key, secret_key)
assert s._save(f, "ss")
assert s.exists(f)
assert s.size(f) == 2
assert s.delete(f)