Exemplo n.º 1
0
 def test_PUT_conflict(self):
     req = Request.blank('/v1/a/c/o.jpg', method='PUT',
                         body='test body')
     # FIXME: we should be able to create the exception without code
     self.storage.object_create = Mock(side_effect=exc.Conflict(409))
     resp = req.get_response(self.app)
     self.assertEqual(409, resp.status_int)
Exemplo n.º 2
0
    def test_container_delete_not_empty(self):
        api = self.api

        api._request = Mock(side_effect=exceptions.Conflict(""))
        api.directory.unlink = Mock(return_value=None)
        name = random_str(32)

        self.assertRaises(exceptions.ContainerNotEmpty, api.container_delete,
                          self.account, name)
Exemplo n.º 3
0
 def test_object_create_conflict_delete_chunks(self):
     name = random_str(16)
     # Simulate a conflict error
     self.api.container.content_create = \
         Mock(side_effect=exc.Conflict(409))
     self.api._blob_client = Mock(wraps=self.api.blob_client)
     # Ensure the error is passed to the upper level
     self.assertRaises(exc.Conflict,
                       self.api.object_create,
                       self.account,
                       name,
                       obj_name=name,
                       data=name)
     # Ensure that the chunk deletion has been called with proper args
     create_kwargs = self.api.container.content_create.call_args[1]
     chunks = create_kwargs['data']['chunks']
     self.api.blob_client.chunk_delete_many.assert_called_once()
     self.assertEqual(
         chunks, self.api.blob_client.chunk_delete_many.call_args[0][0])
     # Ensure the chunks have actually been deleted
     for chunk in chunks:
         self.assertRaises(exc.NotFound, self.api.blob_client.chunk_head,
                           chunk['url'])
Exemplo n.º 4
0
 def test_container_refresh_conflict(self):
     self.api.account.container_reset = Mock(
         side_effect=exceptions.Conflict("No update needed"))
     self.assertRaises(
         exceptions.Conflict, self.api.container_refresh, self.account,
         self.container)