Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
1e1d6f27
Commit
1e1d6f27
authored
Aug 05, 2013
by
Stavros Sachtouris
Browse files
Tide up sopme functional test code
parent
6e50fed4
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/clients/livetest/image.py
View file @
1e1d6f27
...
...
@@ -85,9 +85,7 @@ class Image(livetest.Generic):
f
.
close
()
r
=
self
.
client
.
register
(
self
.
imgname
,
self
.
location
,
params
=
dict
(
is_public
=
True
))
self
.
imgname
,
self
.
location
,
params
=
dict
(
is_public
=
True
))
self
.
_imglist
[
self
.
imgname
]
=
dict
(
name
=
r
[
'name'
],
id
=
r
[
'id'
])
self
.
_imgdetails
[
self
.
imgname
]
=
r
...
...
kamaki/clients/livetest/pithos.py
View file @
1e1d6f27
...
...
@@ -174,12 +174,10 @@ class Pithos(livetest.Generic):
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
account_head
(
if_modified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
if_modified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
account_head
(
if_unmodified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
if_unmodified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -217,12 +215,10 @@ class Pithos(livetest.Generic):
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
account_get
(
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
account_get
(
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -258,8 +254,7 @@ class Pithos(livetest.Generic):
self
.
client
.
set_account_group
(
grpName
,
[
u1
,
u3
])
r
=
self
.
client
.
get_account_group
()
self
.
assertEqual
(
r
[
'x-account-group-'
+
grpName
],
'%s,%s'
%
(
u1
,
u3
))
r
[
'x-account-group-'
+
grpName
],
'%s,%s'
%
(
u1
,
u3
))
except
:
print
(
'
\t
Invalid user id %s (it is ok, though)'
%
u3
)
self
.
client
.
del_account_group
(
grpName
)
...
...
@@ -268,8 +263,7 @@ class Pithos(livetest.Generic):
mprefix
=
'meta'
+
unicode
(
self
.
now
)
self
.
client
.
set_account_meta
({
mprefix
+
'1'
:
'v1'
,
mprefix
+
'2'
:
'v2'
})
mprefix
+
'1'
:
'v1'
,
mprefix
+
'2'
:
'v2'
})
r
=
self
.
client
.
get_account_meta
()
self
.
assertEqual
(
r
[
'x-account-meta-'
+
mprefix
+
'1'
],
'v1'
)
self
.
assertEqual
(
r
[
'x-account-meta-'
+
mprefix
+
'2'
],
'v2'
)
...
...
@@ -312,12 +306,10 @@ class Pithos(livetest.Generic):
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
container_head
(
if_modified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
if_modified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
container_head
(
if_unmodified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
if_unmodified_since
=
now_formated
,
success
=
(
204
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -377,12 +369,10 @@ class Pithos(livetest.Generic):
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
container_get
(
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
container_get
(
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -550,9 +540,7 @@ class Pithos(livetest.Generic):
self
.
assertTrue
(
len
(
r
[
0
])
>
1
)
self
.
client
.
purge_container
()
self
.
assertRaises
(
ClientError
,
self
.
client
.
get_object_versionlist
,
'test'
)
ClientError
,
self
.
client
.
get_object_versionlist
,
'test'
)
def
_test_0080_recreate_deleted_data
(
self
):
self
.
_init_data
()
...
...
@@ -576,30 +564,21 @@ class Pithos(livetest.Generic):
self
.
assertEqual
(
r
.
status_code
,
200
)
r
=
self
.
client
.
object_head
(
obj
,
if_etag_not_match
=
etag
,
success
=
(
200
,
412
,
304
))
obj
,
if_etag_not_match
=
etag
,
success
=
(
200
,
412
,
304
))
self
.
assertNotEqual
(
r
.
status_code
,
200
)
r
=
self
.
client
.
object_head
(
obj
,
version
=
40
,
if_etag_match
=
etag
,
success
=
412
)
obj
,
version
=
40
,
if_etag_match
=
etag
,
success
=
412
)
self
.
assertEqual
(
r
.
status_code
,
412
)
"""Check and if(un)modified_since"""
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
object_head
(
obj
,
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
obj
,
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
object_head
(
obj
,
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
obj
,
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -626,18 +605,13 @@ class Pithos(livetest.Generic):
rangestr
=
'bytes=%s-%s'
%
(
osize
/
3
,
osize
/
2
)
r
=
self
.
client
.
object_get
(
obj
,
data_range
=
rangestr
,
success
=
(
200
,
206
))
obj
,
data_range
=
rangestr
,
success
=
(
200
,
206
))
partsize
=
int
(
r
.
headers
[
'content-length'
])
self
.
assertTrue
(
0
<
partsize
and
partsize
<=
1
+
osize
/
3
)
rangestr
=
'bytes=%s-%s'
%
(
osize
/
3
,
osize
/
2
)
r
=
self
.
client
.
object_get
(
obj
,
data_range
=
rangestr
,
if_range
=
True
,
success
=
(
200
,
206
))
obj
,
data_range
=
rangestr
,
if_range
=
True
,
success
=
(
200
,
206
))
partsize
=
int
(
r
.
headers
[
'content-length'
])
self
.
assertTrue
(
0
<
partsize
and
partsize
<=
1
+
osize
/
3
)
...
...
@@ -651,14 +625,10 @@ class Pithos(livetest.Generic):
for
format
in
self
.
client
.
DATE_FORMATS
:
now_formated
=
self
.
now_unformated
.
strftime
(
format
)
r1
=
self
.
client
.
object_get
(
obj
,
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
obj
,
if_modified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc1
=
r1
.
status_code
r2
=
self
.
client
.
object_get
(
obj
,
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
obj
,
if_unmodified_since
=
now_formated
,
success
=
(
200
,
304
,
412
))
sc2
=
r2
.
status_code
self
.
assertNotEqual
(
sc1
,
sc2
)
...
...
@@ -669,8 +639,7 @@ class Pithos(livetest.Generic):
src_f
=
self
.
create_large_file
(
f_size
)
print
(
'
\t
Uploading...'
)
r
=
self
.
client
.
upload_object
(
trg_fname
,
src_f
,
container_info_cache
=
container_info_cache
)
trg_fname
,
src_f
,
container_info_cache
=
container_info_cache
)
print
(
'
\t
Downloading...'
)
self
.
files
.
append
(
NamedTemporaryFile
())
dnl_f
=
self
.
files
[
-
1
]
...
...
@@ -686,8 +655,7 @@ class Pithos(livetest.Generic):
for
pos
in
(
0
,
f_size
/
2
,
f_size
-
256
):
src_f
.
seek
(
pos
)
tmp_s
=
self
.
client
.
download_to_string
(
trg_fname
,
range_str
=
'%s-%s'
%
(
pos
,
(
pos
+
128
)))
trg_fname
,
range_str
=
'%s-%s'
%
(
pos
,
(
pos
+
128
)))
self
.
assertEqual
(
tmp_s
,
src_f
.
read
(
len
(
tmp_s
)))
print
(
'
\t
Uploading KiBs as strings...'
)
trg_fname
=
'fromString_%s'
%
self
.
now
...
...
@@ -704,8 +672,7 @@ class Pithos(livetest.Generic):
src_f
=
self
.
create_boring_file
(
42
)
print
(
'
\t
Uploading boring file...'
)
self
.
client
.
upload_object
(
trg_fname
,
src_f
,
container_info_cache
=
container_info_cache
)
trg_fname
,
src_f
,
container_info_cache
=
container_info_cache
)
print
(
'
\t
Downloading boring file...'
)
self
.
files
.
append
(
NamedTemporaryFile
())
dnl_f
=
self
.
files
[
-
1
]
...
...
@@ -783,9 +750,7 @@ class Pithos(livetest.Generic):
"""Check content_type and content_length"""
tmpdir
=
'dir'
+
unicode
(
self
.
now
)
r
=
self
.
client
.
object_put
(
tmpdir
,
content_type
=
'application/directory'
,
content_length
=
0
)
tmpdir
,
content_type
=
'application/directory'
,
content_length
=
0
)
r
=
self
.
client
.
get_object_info
(
tmpdir
)
self
.
assertEqual
(
r
[
'content-type'
],
'application/directory'
)
...
...
@@ -1162,9 +1127,7 @@ class Pithos(livetest.Generic):
"""Check permissions"""
self
.
client
.
set_object_sharing
(
obj
,
read_permission
=
[
'u4'
,
'u5'
],
write_permission
=
[
'u4'
])
obj
,
read_permission
=
[
'u4'
,
'u5'
],
write_permission
=
[
'u4'
])
r
=
self
.
client
.
get_object_sharing
(
obj
)
self
.
assertTrue
(
'read'
in
r
)
self
.
assertTrue
(
'u5'
in
r
[
'read'
])
...
...
@@ -1249,12 +1212,10 @@ class Pithos(livetest.Generic):
content_type
=
'application/octet-stream'
)
self
.
client
.
create_object_by_manifestation
(
mobj
,
content_type
=
'application/octet-stream'
)
mobj
,
content_type
=
'application/octet-stream'
)
r
=
self
.
client
.
object_post
(
mobj
,
manifest
=
'%s/%s'
%
(
self
.
client
.
container
,
mobj
))
mobj
,
manifest
=
'%s/%s'
%
(
self
.
client
.
container
,
mobj
))
r
=
self
.
client
.
object_get
(
mobj
)
self
.
assertEqual
(
r
.
text
,
txt
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment