Example #1
0
 def test_upload_folder_with_files(self):
     client = self.client
     up = client.upload_file
     client.upload_file = Mock()
     client.connection.head_container = Mock()
     client.connection.put_container = Mock()
     cont_name = utils.random_name()
     cont = client.create_container(cont_name)
     gobj = client.get_object
     client.get_object = Mock(return_value=self.fake_object)
     safu = client._should_abort_folder_upload
     client._should_abort_folder_upload = Mock(return_value=False)
     upprog = client._update_progress
     client._update_progress = Mock()
     num_files = 10
     fake_upload_key = "abcd"
     with utils.SelfDeletingTempDirectory() as tmpdir:
         for idx in xrange(num_files):
             nm = "file%s" % idx
             pth = os.path.join(tmpdir, nm)
             open(pth, "w").write("test")
         uploader = FakeFolderUploader(tmpdir, cont, "", fake_upload_key,
                 client)
         # Note that the fake moved the actual run() code to a
         # different method
         uploader.actual_run()
         self.assertEqual(client.upload_file.call_count, num_files)
     client.get_object = gobj
     client.upload_file = up
     client._should_abort_folder_upload = safu
     client._update_progress = upprog
Example #2
0
 def test_upload_folder_with_files(self):
     client = self.client
     up = client.upload_file
     client.upload_file = Mock()
     client.connection.head_container = Mock()
     client.connection.put_container = Mock()
     cont_name = utils.random_name()
     cont = client.create_container(cont_name)
     gobj = client.get_object
     client.get_object = Mock(return_value=self.fake_object)
     safu = client._should_abort_folder_upload
     client._should_abort_folder_upload = Mock(return_value=False)
     upprog = client._update_progress
     client._update_progress = Mock()
     num_files = 10
     fake_upload_key = "abcd"
     with utils.SelfDeletingTempDirectory() as tmpdir:
         for idx in xrange(num_files):
             nm = "file%s" % idx
             pth = os.path.join(tmpdir, nm)
             open(pth, "w").write("test")
         uploader = FakeFolderUploader(tmpdir, cont, "", fake_upload_key,
                                       client)
         # Note that the fake moved the actual run() code to a
         # different method
         uploader.actual_run()
         self.assertEqual(client.upload_file.call_count, num_files)
     client.get_object = gobj
     client.upload_file = up
     client._should_abort_folder_upload = safu
     client._update_progress = upprog