def test_BootEntry__getitem__(self): from boom.osprofile import OsProfile, load_profiles load_profiles() from boom.bootloader import (BOOT_VERSION, BOOT_TITLE, BOOT_MACHINE_ID, BOOT_LINUX, BOOT_INITRD, BOOT_OPTIONS, BOOT_DEVICETREE) xtitle = "title" xmachine_id = "ffffffff" xversion = "4.11.5-100.fc24.x86_64" xlinux = "/vmlinuz-4.11.5-100.fc24.x86_64" xinitrd = "/initramfs-4.11.5-100.fc24.x86_64.img" xoptions = "root=/dev/sda5 ro rhgb quiet" xdevicetree = "device.tree" bp = BootParams(xversion, root_device="/dev/sda5") be = BootEntry(title=xtitle, machine_id=xmachine_id, boot_params=bp, allow_no_dev=True) be.devicetree = xdevicetree self.assertEqual(be[BOOT_VERSION], "4.11.5-100.fc24.x86_64") self.assertEqual(be[BOOT_TITLE], "title") self.assertEqual(be[BOOT_MACHINE_ID], "ffffffff") self.assertEqual(be[BOOT_LINUX], xlinux) self.assertEqual(be[BOOT_INITRD], xinitrd) self.assertEqual(be[BOOT_OPTIONS], xoptions) self.assertEqual(be[BOOT_DEVICETREE], xdevicetree)
def test_BootEntry_items(self): from boom.osprofile import OsProfile, load_profiles load_profiles() os_id = "9cb53ddda889d6285fd9ab985a4c47025884999f" osp = boom.osprofile.get_os_profile_by_id(os_id) xkeys = [ 'BOOT_TITLE', 'BOOT_MACHINE_ID', 'BOOT_LINUX', 'BOOT_INITRD', 'BOOT_OPTIONS', 'BOOT_VERSION' ] xvalues = [ 'title', 'ffffffff', '/vmlinuz-4.11.5-100.fc24.x86_64', '/initramfs-4.11.5-100.fc24.x86_64.img', 'root=/dev/sda5 ro rhgb quiet', '4.11.5-100.fc24.x86_64' ] xitems = list(zip(xkeys, xvalues)) bp = BootParams("4.11.5-100.fc24.x86_64", root_device="/dev/sda5") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, osprofile=osp, allow_no_dev=True) self.assertEqual(be.items(), xitems)
def setUp(self): """setUp() Set up a test fixture for the BootEntryTests class. Defines standard OsProfile, BootParams, and BootEntry objects for use in these tests. """ reset_sandbox() # Sandbox paths boot_sandbox = join(SANDBOX_PATH, "boot") boom_sandbox = join(SANDBOX_PATH, "boot/boom") loader_sandbox = join(SANDBOX_PATH, "boot/loader") # Initialise sandbox from master makedirs(boot_sandbox) shutil.copytree(self.boom_path, boom_sandbox) shutil.copytree(self.loader_path, loader_sandbox) # Set boom paths boom.set_boot_path(boot_sandbox) # Load test OsProfile and BootEntry data load_profiles() load_entries()
def test_BootEntry__getitem__bad_key_raises(self): from boom.osprofile import OsProfile, load_profiles load_profiles() bp = BootParams("4.11.5-100.fc24.x86_64", root_device="/dev/sda5") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp) with self.assertRaises(TypeError) as cm: be[123]
def test_match_OsProfile_to_BootEntry(self): from boom.osprofile import OsProfile, load_profiles load_profiles() xos_id = "6bf746bb7231693b2903585f171e4290ff0602b5" bp = BootParams("4.11.5-100.fc24.x86_64", root_device="/dev/sda5") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, allow_no_dev=True) self.assertEqual(be._osp.os_id, xos_id)
def setUp(self): """Set up a test fixture for the BootEntryTests class. Defines standard OsProfile, BootParams, and BootEntry objects for use in these tests. """ reset_sandbox() # Sandbox paths boot_sandbox = join(SANDBOX_PATH, "boot") boom_sandbox = join(SANDBOX_PATH, "boot/boom") loader_sandbox = join(SANDBOX_PATH, "boot/loader") # Initialise sandbox from master makedirs(boot_sandbox) shutil.copytree(self.boom_path, boom_sandbox) shutil.copytree(self.loader_path, loader_sandbox) # Set boom paths boom.set_boot_path(boot_sandbox) # Load test OsProfile and BootEntry data load_profiles() load_entries() # Define a new, test OsProfile that is never included in the # standard set distributed with boom. To be used only for # formatting BootEntry objects for testing. osp = OsProfile(name="Distribution", short_name="distro", version="1 (Workstation Edition)", version_id="1") osp.uname_pattern = "di1" osp.kernel_pattern = "/vmlinuz-%{version}" osp.initramfs_pattern = "/initramfs-%{version}.img" osp.root_opts_lvm2 = "rd.lvm.lv=%{lvm_root_lv}" osp.root_opts_btrfs = "rootflags=%{btrfs_subvolume}" osp.options = "root=%{root_device} %{root_opts} rhgb quiet" self.test_osp = osp # Define a standard set of test BootParams bp = BootParams("1.1.1.fc24", root_device="/dev/vg/lv", lvm_root_lv="vg/lv") self.test_bp = bp # Define a synthetic BootEntry for testing be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, osprofile=osp, allow_no_dev=True) self.test_be = be
def test_BootEntry_keys(self): from boom.osprofile import OsProfile, load_profiles load_profiles() xkeys = [ 'BOOM_ENTRY_TITLE', 'BOOM_ENTRY_MACHINE_ID', 'BOOM_ENTRY_ARCHITECTURE', 'BOOM_ENTRY_LINUX', 'BOOM_ENTRY_INITRD', 'BOOM_ENTRY_OPTIONS', 'BOOM_ENTRY_VERSION' ] bp = BootParams("4.11.5-100.fc24.x86_64", root_device="/dev/sda5") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, allow_no_dev=True) self.assertEqual(be.keys(), xkeys)
def test_BootEntry_values(self): from boom.osprofile import OsProfile, load_profiles load_profiles() xvalues = [ 'title', 'ffffffff', '/vmlinuz-4.11.5-100.fc24.x86_64', '/initramfs-4.11.5-100.fc24.x86_64.img', 'root=/dev/sda5 ro rhgb quiet', '4.11.5-100.fc24.x86_64' ] bp = BootParams("4.11.5-100.fc24.x86_64", root_device="/dev/sda5") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, allow_no_dev=True) self.assertEqual(be.values(), xvalues)
def setUp(self): reset_sandbox() # Sandbox paths boot_sandbox = join(SANDBOX_PATH, "boot") boom_sandbox = join(SANDBOX_PATH, "boot/boom") loader_sandbox = join(SANDBOX_PATH, "boot/loader") # Initialise sandbox from master makedirs(boot_sandbox) shutil.copytree(self.boom_path, boom_sandbox) shutil.copytree(self.loader_path, loader_sandbox) # Set boom paths boom.set_boot_path(boot_sandbox) # Reset profiles, entries, and host profiles to known state. load_profiles() load_entries() load_host_profiles()