From 324fee8fa039d4bf9ae6fd683aba5d5d021b126d Mon Sep 17 00:00:00 2001 From: Stavros Sachtouris Date: Wed, 13 Mar 2013 14:48:54 +0200 Subject: [PATCH] Finetest Storage.copy_object --- kamaki/clients/storage/test.py | 42 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/kamaki/clients/storage/test.py b/kamaki/clients/storage/test.py index 45b1ca7..698bf71 100644 --- a/kamaki/clients/storage/test.py +++ b/kamaki/clients/storage/test.py @@ -355,37 +355,25 @@ class Storage(TestCase): expected = [call('%s%s' % (prfx, k), v) for k, v in metas.items()] self.assertEqual(SH.mock_calls, expected) - """ - @patch('%s.object_put' % pithos_pkg, return_value=FR()) - def test_copy_object(self, put): + @patch('%s.put' % storage_pkg, return_value=FR()) + @patch('%s.set_header' % storage_pkg) + def test_copy_object(self, SH, put): src_cont = 'src-c0nt41n3r' src_obj = 'src-0bj' dst_cont = 'dst-c0nt41n3r' - dst_obj = 'dst-0bj' - expected = call( - src_obj, - content_length=0, - source_account=None, - success=201, - copy_from='/%s/%s' % (src_cont, src_obj), - delimiter=None, - content_type=None, - source_version=None, - public=False) - self.client.copy_object(src_cont, src_obj, dst_cont) - self.assertEqual(put.mock_calls[-1], expected) - self.client.copy_object(src_cont, src_obj, dst_cont, dst_obj) - self.assertEqual(put.mock_calls[-1][1], (dst_obj,)) - kwargs = dict( - source_version='src-v3r510n', - source_account='src-4cc0un7', - public=True, - content_type='c0n73n7Typ3', - delimiter='5') - self.client.copy_object(src_cont, src_obj, dst_cont, **kwargs) - for k, v in kwargs.items(): - self.assertEqual(v, put.mock_calls[-1][2][k]) + for dst_obj in (None, 'dst-0bj'): + dst_path = dst_obj or src_obj + path = '/%s/%s/%s' % (self.client.account, dst_cont, dst_path) + self.client.copy_object(src_cont, src_obj, dst_cont, dst_obj) + self.assertEqual(put.mock_calls[-1], call(path, success=201)) + kwargs = { + 'X-Copy-From': '/%s/%s' % (src_cont, src_obj), + 'Content-Length': 0} + self.assertEqual( + SH.mock_calls[-2:], + [call(k, v) for k, v in kwargs.items()]) + """ @patch('%s.object_put' % pithos_pkg, return_value=FR()) def test_move_object(self, put): src_cont = 'src-c0nt41n3r' -- 1.7.10.4