'Tests that creating an image with the v2 API with a size of 0 will
trigger a call to set the disk and container formats.'

@mock.patch('nova.image.glance._translate_from_glance')
@mock.patch('nova.image.glance._translate_to_glance')
def test_create_success_v2_force_activate(self, trans_to_mock, trans_from_mock):

    translated = {'name': mock.sentinel.name}
    trans_to_mock.return_value = translated
    trans_from_mock.return_value = mock.sentinel.trans_from
    image_mock = {'size': 0}
    client = mock.MagicMock()
    client.call.return_value = {'id': '123'}
    ctx = mock.sentinel.ctx
    service = glance.GlanceImageServiceV2(client)
    with mock.patch.object(service, '_get_image_create_disk_format_default', return_value='vdi'):
        image_meta = service.create(ctx, image_mock)
    trans_to_mock.assert_called_once_with(image_mock)
    create_call_kwargs = client.call.call_args_list[0][1]
    self.assertEqual('vdi', create_call_kwargs['disk_format'])
    self.assertEqual('bare', create_call_kwargs['container_format'])
    trans_from_mock.assert_called_once_with({'id': '123'})
    self.assertEqual(mock.sentinel.trans_from, image_meta)
