Finetest Storage.create_directory
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Wed, 13 Mar 2013 10:58:15 +0000 (12:58 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Wed, 13 Mar 2013 10:58:15 +0000 (12:58 +0200)
kamaki/clients/pithos/test.py
kamaki/clients/storage/test.py

index cee1c1f..02d3bbd 100644 (file)
@@ -336,18 +336,6 @@ class Pithos(TestCase):
         for arg, val in kwargs.items():
             self.assertEqual(OP.mock_calls[-2][2][arg], val)
 
-    @patch('%s.put' % pithos_pkg, return_value=FR())
-    @patch('%s.set_header' % client_pkg)
-    def test_create_directory(self, SH, put):
-        cont = self.client.container
-        exp_shd = [
-            call('Content-Type', 'application/directory'),
-            call('Content-length', '0')]
-        exp_put = [call('/%s/%s/%s' % (user_id, cont, obj), success=201)]
-        self.client.create_directory(obj)
-        self.assertEqual(PC.set_header.mock_calls, exp_shd)
-        self.assertEqual(put.mock_calls, exp_put)
-
     def test_get_object_info(self):
         FR.headers = object_info
         version = 'v3r510n'
@@ -359,8 +347,7 @@ class Pithos(TestCase):
                 call(obj, version=None),
                 call(obj, version=version)])
         with patch.object(
-                PC,
-                'object_head',
+                PC, 'object_head',
                 side_effect=ClientError('Obj not found', 404)):
             self.assertRaises(
                 ClientError,
index d1c580d..109d382 100644 (file)
@@ -316,26 +316,15 @@ class Storage(TestCase):
         self.assertEqual(SH.mock_calls, exp_shd)
         self.assertEqual(put.mock_calls, exp_put)
 
-    """
-    def test_get_object_info(self):
+    @patch('%s.head' % storage_pkg, return_value=FR())
+    def test_get_object_info(self, head):
         FR.headers = object_info
-        version = 'v3r510n'
-        with patch.object(PC, 'object_head', return_value=FR()) as head:
-            r = self.client.get_object_info(obj)
-            self.assertEqual(r, object_info)
-            r = self.client.get_object_info(obj, version=version)
-            self.assertEqual(head.mock_calls, [
-                call(obj, version=None),
-                call(obj, version=version)])
-        with patch.object(
-                PC,
-                'object_head',
-                side_effect=ClientError('Obj not found', 404)):
-            self.assertRaises(
-                ClientError,
-                self.client.get_object_info,
-                obj, version=version)
+        path = '/%s/%s/%s' % (self.client.account, self.client.container, obj)
+        r = self.client.get_object_info(obj)
+        self.assertEqual(r, object_info)
+        self.assertEqual(head.mock_calls[-1], call(path, success=200))
 
+    """
     @patch('%s.get_object_info' % pithos_pkg, return_value=object_info)
     def test_get_object_meta(self, GOI):
         expected = dict()