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
e9ac514e
Commit
e9ac514e
authored
Apr 12, 2013
by
Stavros Sachtouris
Browse files
Add if-etag-match to pithos client upload
parent
2ec852fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/clients/pithos/__init__.py
View file @
e9ac514e
...
...
@@ -291,6 +291,7 @@ class PithosClient(PithosRestClient):
hash_cb
=
None
,
upload_cb
=
None
,
etag
=
None
,
if_etag_match
=
None
,
if_not_exist
=
None
,
content_encoding
=
None
,
content_disposition
=
None
,
...
...
@@ -309,6 +310,9 @@ class PithosClient(PithosRestClient):
:param etag: (str)
:param if_etag_match: (str) Push that value to if-match header at file
creation
:param if_not_exist: (bool) If true, the file will be uploaded ONLY if
it does not exist remotely, otherwise the operation will fail.
Involves the case of an object with the same path is created while
...
...
@@ -396,6 +400,7 @@ class PithosClient(PithosRestClient):
format
=
'json'
,
hashmap
=
True
,
content_type
=
content_type
,
if_etag_match
=
if_etag_match
,
if_etag_not_match
=
'*'
if
if_not_exist
else
None
,
etag
=
etag
,
json
=
hashmap
,
...
...
kamaki/clients/pithos/test.py
View file @
e9ac514e
...
...
@@ -910,6 +910,7 @@ class PithosClient(TestCase):
tmpFile
.
seek
(
0
)
kwargs
=
dict
(
etag
=
's0m3E74g'
,
if_etag_match
=
'if etag match'
,
if_not_exist
=
True
,
content_type
=
ctype
,
content_disposition
=
ctype
+
'd15p051710n'
,
...
...
@@ -917,9 +918,11 @@ class PithosClient(TestCase):
content_encoding
=
'802.11'
)
self
.
client
.
upload_object
(
obj
,
tmpFile
,
**
kwargs
)
kwargs
.
pop
(
'if_not_exist'
)
ematch
=
kwargs
.
pop
(
'if_etag_match'
)
etag
=
kwargs
.
pop
(
'etag'
)
for
arg
,
val
in
kwargs
.
items
():
self
.
assertEqual
(
OP
.
mock_calls
[
-
2
][
2
][
arg
],
val
)
self
.
assertEqual
(
OP
.
mock_calls
[
-
1
][
2
][
'if_etag_match'
],
ematch
)
self
.
assertEqual
(
OP
.
mock_calls
[
-
1
][
2
][
'if_etag_not_match'
],
'*'
)
self
.
assertEqual
(
OP
.
mock_calls
[
-
1
][
2
][
'etag'
],
etag
)
...
...
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