def test_resizable(self):
        """ Test resizable property of unformatted devices. """
        # Devices with no (or unrecognized) formatting should not be resizable.
        device = StorageDevice("testdev1", exists=True, size=Size("100 G"), fmt=get_format("ext4", exists=True))
        device._resizable = True
        with patch.object(device, "_format", exists=True, resizable=True):
            self.assertTrue(device.resizable)

        device = StorageDevice("testdev1", exists=True, size=Size("100 G"))
        device._resizable = True
        self.assertFalse(device.resizable)
    def test_resizable(self):
        """ Test resizable property of unformatted devices. """
        # Devices with no (or unrecognized) formatting should not be resizable.
        device = StorageDevice("testdev1", exists=True, size=Size("100 G"), fmt=get_format("ext4", exists=True))
        device._resizable = True
        with patch.object(device, "_format", exists=True, resizable=True):
            self.assertTrue(device.resizable)

        device = StorageDevice("testdev1", exists=True, size=Size("100 G"))
        device._resizable = True
        self.assertFalse(device.resizable)
Exemple #3
0
    def test_is_device_shrinkable(self, update_size_info):
        """Test IsDeviceShrinkable."""
        self.module.on_storage_changed(create_storage())

        dev1 = StorageDevice("dev1",
                             exists=True,
                             size=Size("10 GiB"),
                             fmt=get_format(None, exists=True))

        self._add_device(dev1)
        self.assertEqual(self.interface.IsDeviceShrinkable("dev1"), False)

        dev1._resizable = True
        dev1.format._resizable = True
        dev1.format._min_size = Size("1 GiB")
        self.assertEqual(self.interface.IsDeviceShrinkable("dev1"), True)

        dev1.format._min_size = Size("10 GiB")
        self.assertEqual(self.interface.IsDeviceShrinkable("dev1"), False)