tests package

Submodules

tests.action_test module

class tests.action_test.DeviceActionTestCase(methodName='runTest')

Bases: tests.storagetestcase.StorageTestCase

DeviceActionTestSuite

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()

Create something like a preexisting autopart on two disks (sda,sdb).

The other two disks (sdc,sdd) are left for individual tests to use.

test_action_apply_cancel()
test_action_creation()

Verify correct operation of action class constructors.

test_action_dependencies()

Verify correct functioning of action dependencies.

test_action_obsoletes()

Verify correct operation of DeviceAction.obsoletes.

test_action_pruning()

Verify correct functioning of action pruning.

test_action_registration()

Verify correct operation of action registration and cancelling.

test_action_sorting(*args, **kwargs)

Verify correct functioning of action sorting.

test_actions()

Verify correct management of actions.

  • action creation/registration/cancellation
    • ActionCreateDevice adds device to tree
    • ActionDestroyDevice removes device from tree
    • ActionCreateFormat sets device.format in tree
    • ActionDestroyFormat unsets device.format in tree
    • cancelled action’s registration side-effects reversed
    • failure to register destruction of non-leaf device
    • failure to register creation of device already in tree?
    • failure to register destruction of device not in tree?
  • action pruning
    • non-existent-device create..destroy cycles removed
      • all actions on this device should get removed
    • all actions pruned from to-be-destroyed devices
      • resize, format, &c
    • redundant resize/format actions pruned
      • last one registered stays
  • action sorting
    • destroy..resize..create

    • creation
      • leaves-last, including formatting
    • destruction
      • leaves-first
test_container_actions()

tests.clearpart_test module

class tests.clearpart_test.ClearPartTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()
tearDown()
test_initialize_disk()

magic partitions non-empty partition table

test_recursive_remove()

protected device at various points in stack

test_should_clear()

Test the Blivet.should_clear method.

tests.devicefactory_test module

class tests.devicefactory_test.DeviceFactoryTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

device_class = None

device class to expect from devicefactory

device_type = None

device type constant to pass to devicefactory.get_device_factory

encryption_supported = True

whether encryption of this device type is supported by blivet

setUp()
test_device_factory()
test_get_free_disk_space()
test_normalize_size()
class tests.devicefactory_test.LVMFactoryTestCase(methodName='runTest')

Bases: tests.devicefactory_test.DeviceFactoryTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

device_class

alias of LVMLogicalVolumeDevice

device_type = 0
test_device_factory()
test_get_container()
class tests.devicefactory_test.LVMThinPFactoryTestCase(methodName='runTest')

Bases: tests.devicefactory_test.LVMFactoryTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

device_class

alias of LVMLogicalVolumeDevice

device_type = 5
encryption_supported = False
class tests.devicefactory_test.MDFactoryTestCase(methodName='runTest')

Bases: tests.devicefactory_test.DeviceFactoryTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

device_class

alias of MDRaidArrayDevice

device_type = 1
test_device_factory()
test_mdfactory()
class tests.devicefactory_test.PartitionFactoryTestCase(methodName='runTest')

Bases: tests.devicefactory_test.DeviceFactoryTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

device_class

alias of PartitionDevice

device_type = 2
test_bug1178884()

tests.devicetree_test module

class tests.devicetree_test.BlivetResetTestCase(methodName='runTest')

Bases: tests.imagebackedtestcase.ImageBackedTestCase

A class to test the results of Blivet.reset (and DeviceTree.populate).

Create a device stack on disk images, catalog a set of attributes of every device we created, reset the Blivet instance, and then verify that the devices are all discovered and have attributes matching those we cataloged previously.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

collect_expected_data()

Collect the attribute data we plan to validate later.

find_device(attr_dict)
run_test()

Verify that the devices and their attributes match across reset.

setUp()
skip_attr(device, attr)

Return True if attr should not be checked for device.

tearDown()

Clean up after testing is complete.

class tests.devicetree_test.DeviceTreeTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_resolve_device()
class tests.devicetree_test.LVMOnMDTestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

class tests.devicetree_test.LVMRaidTestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()
class tests.devicetree_test.LVMSnapShotTestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()
class tests.devicetree_test.LVMTestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Test that the devicetree can populate with the product of autopart.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

class tests.devicetree_test.LVMThinSnapShotTestCase(methodName='runTest')

Bases: tests.devicetree_test.LVMThinpTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()
class tests.devicetree_test.LVMThinpTestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

class tests.devicetree_test.MDRaid0TestCase(methodName='runTest')

Bases: tests.devicetree_test.BlivetResetTestCase

Verify correct detection of MD RAID0 arrays.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

level = 'raid0'
set_up_disks()
skip_attr(device, attr)
tests.devicetree_test.recursive_getattr(x, attr, default=None)

Resolve a possibly-dot-containing attribute name.

tests.events_test module

class tests.events_test.EventManagerTest(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

testEventMask()
class tests.events_test.FakeEventManager(handler_cb=None, notify_cb=None, error_cb=None)

Bases: blivet.events.manager.EventManager

disable()
enable()
enabled()

tests.imagebackedtestcase module

class tests.imagebackedtestcase.ImageBackedTestCase(methodName='runTest')

Bases: unittest.case.TestCase

A class to encapsulate testing of blivet using block devices.

The basic idea is you create some scratch block devices and then run some test code on them.

disks defines the set of disk images.

_set_up_storage() is where you specify the initial layout of the disks. It will be written to the disk images in set_up_storage().

You then write test methods as usual that use the disk images, which will be cleaned up and removed when each test method finishes.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

disks = {'disk2': Size('2 GiB'), 'disk1': Size('2 GiB')}

The names and sizes of the disk images to create/use.

initialize_disks = True

Whether or not to create a disklabel on the disks.

setUp()

Do any setup required prior to running a test.

set_up_disks()

Create disk image files to build the test’s storage on.

If you are actually creating the disk image files here don’t forget to set the initialize_disks flag so they get a fresh disklabel when clear_partitions gets called from create_storage later.

set_up_storage()

Create a device stack on top of disk images for this test to run on.

This will write the configuration to whatever disk images are defined in set_up_disks.

tests.lib module

tests.lib.assertVerboseEqual(left, right, msg=None)
tests.lib.assertVerboseListEqual(left, right, msg=None)

tests.loopbackedtestcase module

class tests.loopbackedtestcase.LoopBackedTestCase(methodName='run_test', device_spec=None, block_size=None)

Bases: unittest.case.TestCase

LoopBackedTestCase manages loop devices.

It constructs loop devices according to loop_device_spec, sets them up, and tears them down again.

Parameters:
  • device_spec (list of Size or NoneType) – list containing the size of each loop device
  • block_size (Size or NoneType) – block size for dd command when making devices
DEFAULT_BLOCK_SIZE = Size('1 KiB')
DEFAULT_STORE_SIZE = Size('100 MiB')
setUp()
tests.loopbackedtestcase.get_free_loop_dev()

Get the name of the free loop device that losetup reports.

Returns:the name of the free loop device
Return type:str
Raises OSError:on failure
tests.loopbackedtestcase.make_loop_dev(device_name, file_name)

Set up a loop device with a backing store.

Parameters:
  • device_name (str) – the path of the loop device
  • file_name (str) – the path of the backing file
tests.loopbackedtestcase.make_store(file_name, num_blocks=102400, block_size=1024)

Set up the backing store for a loop device.

Parameters:
  • file_name (str) – the path of the backing file
  • num_blocks (int) – the size of file_name in number of blocks
  • block_size (int) – the number of bytes in a block
tests.loopbackedtestcase.remove_loop_dev(device_name)

tests.parentlist_test module

class tests.parentlist_test.ParentListTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_device_parents()

Verify that Device.parents functions as expected.

test_parent_list()

tests.partitioning_test module

class tests.partitioning_test.ExtendedPartitionTestCase(methodName='runTest')

Bases: tests.imagebackedtestcase.ImageBackedTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

disks = {'disk1': Size('2 GiB')}
initialize_disks = False
test_explicit_extended_partitions()

Verify that explicitly requested extended partitions work.

test_implicit_extended_partitions()

Verify management of implicitly requested extended partition.

test_implicit_extended_partitions_installer_mode()
class tests.partitioning_test.PartitioningTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

get_disk(disk_type, primary_count=0, has_extended=False, logical_count=0)

Return a mock representing a parted.Disk.

test_add_partition()
test_align_free_regions()
test_chunk()
test_disk_chunk1()
test_disk_chunk2()
test_next_partition_type()
test_vgchunk()
test_vgchunk_with_cache()
test_vgchunk_with_cache_pvfree()

tests.populator_test module

class tests.populator_test.AppleBootFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.BootFormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of AppleBootFormatPopulator

class tests.populator_test.BootFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_get_helper(*args)
test_match()

Test boot format populator helper match method

class tests.populator_test.DMDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of DMDevicePopulator

test_get_helper(*args)

Test get_device_helper for dm devices.

test_match(*args)

Test matching of dm device populator.

test_run(*args)

Test dm device populator.

class tests.populator_test.DiskDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of DiskDevicePopulator

test_get_helper(*args)

Test get_device_helper for disks.

test_match(*args)

Test matching of disk device populator.

test_run(*args)

Test disk device populator.

class tests.populator_test.DiskLabelPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of DiskLabelFormatPopulator

test_get_helper(*args)

Test get_format_helper for disklabels.

test_match(*args)

Test matching for disklabel format populator.

class tests.populator_test.EFIFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.BootFormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of EFIFormatPopulator

class tests.populator_test.Ext4PopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Test ext4 format populator.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'ext4'
udev_type = 'ext4'
class tests.populator_test.FormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Format types that don’t require special handling use FormatPopulator.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = None
helper_class

alias of FormatPopulator

helper_name
test_get_helper(*args)
test_match()
test_run()
udev_type = None
class tests.populator_test.HFSPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'hfs'
udev_type = 'hfs'
class tests.populator_test.LVMDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of LVMDevicePopulator

test_get_helper(*args)

Test get_device_helper for lvm devices.

test_match(*args)

Test matching of lvm device populator.

test_run(*args)

Test lvm device populator.

class tests.populator_test.LVMFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'lvmpv'
helper_class

alias of LVMFormatPopulator

test_run(*args)

Test lvm format populator.

udev_type = 'LVM2_member'
class tests.populator_test.LoopDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of LoopDevicePopulator

test_get_helper(*args)

Test get_device_helper for loop devices.

test_match(*args)

Test matching of loop device populator.

test_run(*args)

Test loop device populator.

class tests.populator_test.MDDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of MDDevicePopulator

test_get_helper(*args)

Test get_device_helper for md arrays.

test_match(*args)

Test matching of md device populator.

test_run(*args)

Test md device populator.

class tests.populator_test.MDFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'mdmember'
helper_class

alias of MDFormatPopulator

test_run(*args)

Test md format populator.

udev_type = 'linux_raid_member'
class tests.populator_test.MacEFIFormatPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.BootFormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of MacEFIFormatPopulator

class tests.populator_test.MultipathDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of MultipathDevicePopulator

match_auto_patches = ['blivet.udev.device_is_dm_mpath', 'blivet.udev.device_is_dm_partition']
test_get_helper(*args)

Test get_device_helper for multipaths.

test_match(*args)

Test matching of multipath device populator.

test_run(*args)

Test multipath device populator.

class tests.populator_test.OpticalDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of OpticalDevicePopulator

test_get_helper(*args)

Test get_device_helper for optical devices.

test_match(*args)

Test matching of optical device populator.

test_run(*args)

Test optical device populator.

class tests.populator_test.PartitionDevicePopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.PopulatorHelperTestCase

Test partition device populator match method

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class

alias of PartitionDevicePopulator

test_get_helper(*args)

Test get_device_helper for partitions.

test_match(*args)

Test matching for partition device populator.

test_run(*args)

Test partition device populator.

class tests.populator_test.PopulatorHelperTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

helper_class = None
class tests.populator_test.SwapPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'swap'
udev_type = 'swap'
class tests.populator_test.VFATPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'vfat'
udev_type = 'vfat'
class tests.populator_test.XFSPopulatorTestCase(methodName='runTest')

Bases: tests.populator_test.FormatPopulatorTestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

blivet_type = 'xfs'
udev_type = 'xfs'
class tests.populator_test.setupDiskImagesNonZeroSizeTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Test if size of disk images is > 0. Related: rhbz#1252703. This test emulates how anaconda configures its storage.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

disks = {'disk1': Size('2 GiB')}
runTest()
setUp()
tearDown()

tests.size_test module

class tests.size_test.SizeTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_convert_to_precision()
test_convert_to_with_size()
test_exceptions()
test_floating_point_str()
test_human_readable()
test_human_readable_fractional_quantities()
test_leading_zero()
test_min_value()
test_negative()
test_no_units_in_string()
test_partial_bytes()
test_pickling()
test_prefixes()
test_scientific_notation()
test_white_space()
class tests.size_test.TranslationTestCase(methodName='run_test')

Bases: unittest.case.TestCase

setUp()
tearDown()
test_human_readable_translation()
test_make_spec()

Tests for _make_specs().

test_parse_spec()

Tests for parse_spec().

test_round_to_nearest()
test_translated()
class tests.size_test.UtilityMethodsTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_arithmetic()
test_lower_ascii()

Tests for _lower_ascii.

tests.storagetestcase module

class tests.storagetestcase.StorageTestCase(methodName='runTest')

Bases: unittest.case.TestCase

This is a base class for storage test cases. It sets up imports of the blivet package, along with an Anaconda instance and a Storage instance. There are lots of little patches to prevent various pieces of code from trying to access filesystems and/or devices on the host system, along with a couple of convenience methods.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

destroy_all_devices(disks=None)

Remove all devices from the devicetree.

Keyword Arguments:

disks - a list of names of disks to remove partitions from

Note: this is largely ripped off from partitioning.clear_partitions.

new_device(*args, **kwargs)

Return a new Device instance suitable for testing.

new_format(*args, **kwargs)

Return a new DeviceFormat instance suitable for testing.

Keyword Arguments:

device_instance - StorageDevice instance this format will be
created on. This is needed for setup of resizable formats.

All other arguments are passed directly to blivet.formats.get_format.

schedule_create_device(device)

Schedule an action to create the specified device.

Verify that the device is not already in the tree and that the act of scheduling/registering the action also adds the device to the tree.

Return the DeviceAction instance.

schedule_create_format(device, fmt)

Schedule an action to write a new format to a device.

Verify that the device is already in the tree, that it is not already set up to contain the specified format, and that the act of registering/scheduling the action causes the new format to be reflected in the tree.

Return the DeviceAction instance.

schedule_destroy_device(device)

Schedule an action to destroy the specified device.

Verify that the device exists initially and that the act of scheduling/registering the action also removes the device from the tree.

Return the DeviceAction instance.

schedule_destroy_format(device)

Schedule an action to remove a format from a device.

Verify that the device is already in the tree and that the act of registering/scheduling the action causes the new format to be reflected in the tree.

Return the DeviceAction instance.

setUp()
tearDown()

tests.tsort_test module

class tests.tsort_test.TopologicalSortTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

run_test()

tests.udev_test module

class tests.udev_test.UdevTest(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()
tearDown()
test_udev_get_device()
udev_settle_test()
udev_trigger_test()

tests.util_test module

class tests.util_test.MiscTest(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

long_message = True
test_dedup_list()
test_power_of_two()
class tests.util_test.Test(s)

Bases: object

bad_news
good_news
hi
nok
ok
s
say_hi()
class tests.util_test.TestDefaultNamedtuple(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_default_namedtuple()
class tests.util_test.TestRequiresProperty(methodName='runTest')

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_requires_property()

Module contents