Exemplo n.º 1
0
    def test_make_image(self):
        '''
        Test for create a blank virtual machine image file
        of the specified size in megabytes
        '''
        with patch.object(os.path, 'isabs',
                          MagicMock(side_effect=[False, True, True, True])):
            self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), '')

            with patch.object(os.path, 'isdir',
                              MagicMock(side_effect=[False, True, True])):
                self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), '')

                with patch.dict(qemu_img.__salt__,
                                {'cmd.retcode': MagicMock(side_effect=[False, True])}):
                    self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), 'location')
                    self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), '')
Exemplo n.º 2
0
def test_make_image():
    """
    Test for create a blank virtual machine image file
    of the specified size in megabytes
    """
    with patch.object(
        os.path, "isabs", MagicMock(side_effect=[False, True, True, True])
    ):
        assert qemu_img.make_image("location", "size", "fmt") == ""

        with patch.object(os.path, "isdir", MagicMock(side_effect=[False, True, True])):
            assert qemu_img.make_image("location", "size", "fmt") == ""

            with patch.dict(
                qemu_img.__salt__,
                {"cmd.retcode": MagicMock(side_effect=[False, True])},
            ):
                assert qemu_img.make_image("location", "size", "fmt") == "location"
                assert qemu_img.make_image("location", "size", "fmt") == ""
Exemplo n.º 3
0
    def test_make_image(self):
        '''
        Test for create a blank virtual machine image file
        of the specified size in megabytes
        '''
        with patch.object(os.path, 'isabs',
                          MagicMock(side_effect=[False, True, True, True])):
            self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), '')

            with patch.object(os.path, 'isdir',
                              MagicMock(side_effect=[False, True, True])):
                self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'),
                                 '')

                with patch.dict(qemu_img.__salt__,
                                {'cmd.retcode': MagicMock(side_effect=[False,
                                                                       True])}):
                    self.assertEqual(qemu_img.make_image('location', 'size',
                                                         'fmt'), 'location')

                    self.assertEqual(qemu_img.make_image('location', 'size',
                                                         'fmt'), '')