unittest: fsm:bootable,installable
- Unittests for bootable and installable - Fix not bootable, missing False return Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
525ae944b6
commit
f60759d4ab
|
@ -331,6 +331,8 @@ class FilesystemModel(ModelPolicy):
|
||||||
if disk.usedspace > 0 and "/" in disk.mounts:
|
if disk.usedspace > 0 and "/" in disk.mounts:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def bootable(self):
|
def bootable(self):
|
||||||
''' true if one disk has a boot partition '''
|
''' true if one disk has a boot partition '''
|
||||||
log.debug('bootable check')
|
log.debug('bootable check')
|
||||||
|
|
|
@ -142,6 +142,41 @@ class TestFilesystemModel(testtools.TestCase):
|
||||||
print(partitions, diskname)
|
print(partitions, diskname)
|
||||||
self.assertTrue(partitions[0].startswith(diskname))
|
self.assertTrue(partitions[0].startswith(diskname))
|
||||||
|
|
||||||
|
def test_filesystemmodel_installable(self):
|
||||||
|
self.fsm.probe_storage()
|
||||||
|
self.assertEqual(self.fsm.installable(), False)
|
||||||
|
|
||||||
|
# create a partition that installs to root(/)
|
||||||
|
diskname = random.choice(list(self.fsm.info.keys()))
|
||||||
|
disk = self.fsm.get_disk(diskname)
|
||||||
|
disk.add_partition(1, disk.freespace, 'ext4', '/', flag='bios_grub')
|
||||||
|
|
||||||
|
# now we should be installable
|
||||||
|
self.assertEqual(self.fsm.installable(), True)
|
||||||
|
|
||||||
|
def test_filesystemmodel_not_installable(self):
|
||||||
|
self.fsm.probe_storage()
|
||||||
|
|
||||||
|
# create a partition that installs to not root(/)
|
||||||
|
diskname = random.choice(list(self.fsm.info.keys()))
|
||||||
|
disk = self.fsm.get_disk(diskname)
|
||||||
|
disk.add_partition(1, disk.freespace, 'ext4', '/opt', flag='bios_grub')
|
||||||
|
|
||||||
|
# we should not be installable
|
||||||
|
self.assertEqual(self.fsm.installable(), False)
|
||||||
|
|
||||||
|
def test_filesystemmodel_bootable(self):
|
||||||
|
self.fsm.probe_storage()
|
||||||
|
self.assertEqual(self.fsm.bootable(), False)
|
||||||
|
|
||||||
|
# create a partition that installs to root(/)
|
||||||
|
diskname = random.choice(list(self.fsm.info.keys()))
|
||||||
|
disk = self.fsm.get_disk(diskname)
|
||||||
|
disk.add_partition(1, disk.freespace, 'ext4', '/', flag='bios_grub')
|
||||||
|
|
||||||
|
# now we should be installable
|
||||||
|
self.assertEqual(self.fsm.bootable(), True)
|
||||||
|
|
||||||
|
|
||||||
class TestBlockdev(testtools.TestCase):
|
class TestBlockdev(testtools.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Reference in New Issue