Add if-etag-match to pithos client upload
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 12 Apr 2013 12:37:52 +0000 (15:37 +0300)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 12 Apr 2013 12:37:52 +0000 (15:37 +0300)
kamaki/clients/pithos/__init__.py
kamaki/clients/pithos/test.py

index 6cdca02..f73903e 100644 (file)
@@ -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,
index 9dae50b..eec0f55 100644 (file)
@@ -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)