Commit e9ac514e authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Add if-etag-match to pithos client upload

parent 2ec852fc
......@@ -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,
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment