Exemplo n.º 1
0
    def test_create_and_delete_image(self,
                                     mock_random_name,
                                     mock_create_image,
                                     mock_delete_image):
        fake_image = object()
        mock_create_image.return_value = fake_image

        images.CreateAndDeleteImage(self.context).run(
            "cf", "url", "df", fakearg="f")

        mock_create_image.assert_called_once_with(
            "cf", "url", "df", fakearg="f")
        mock_delete_image.assert_called_once_with(fake_image)
Exemplo n.º 2
0
    def test_create_and_delete_image(self):
        image_service = self.mock_image.return_value

        fake_image = fakes.FakeImage(id=1, name="imagexxx")
        image_service.create_image.return_value = fake_image
        call_args = {
            "container_format": "cf",
            "image_location": "url",
            "disk_format": "df",
            "visibility": "vs",
            "min_disk": 0,
            "min_ram": 0
        }

        images.CreateAndDeleteImage(self.context).run("cf", "url", "df", "vs",
                                                      0, 0)

        image_service.create_image.assert_called_once_with(**call_args)
        image_service.delete_image.assert_called_once_with(fake_image.id)