Unittest clients.pithos create directory
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 7 Mar 2013 13:25:16 +0000 (15:25 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 7 Mar 2013 13:25:16 +0000 (15:25 +0200)
kamaki/clients/test/pithos.py

index f5bdbc4..2dec9b4 100644 (file)
@@ -330,3 +330,16 @@ class Pithos(TestCase):
                 content_type=ctype, content_length=42)
             self.assertEqual(PC.set_header.mock_calls, exp_shd)
             self.assertEqual(put.mock_calls, exp_put)
+
+    def test_create_directory(self):
+        PC.set_header = Mock(return_value=None)
+        obj = 'r4nd0m0bj3c7'
+        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)]
+        with patch.object(PC, 'put', return_value=self.FR()) as put:
+            self.client.create_directory(obj)
+            self.assertEqual(PC.set_header.mock_calls, exp_shd)
+            self.assertEqual(put.mock_calls, exp_put)