def test_set_virt_auto_boot(test_autoboot, expectation): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testprofile = Profile(test_manager) # Act with expectation: utils.set_virt_auto_boot(testprofile, test_autoboot) # Assert assert isinstance(testprofile.virt_auto_boot, int) assert testprofile.virt_auto_boot == 1 or testprofile.virt_auto_boot == 0
def test_set_virt_file_size(): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testprofile = Profile(test_manager) # Act # TODO: Test multiple disks via comma separation utils.set_virt_file_size(testprofile, "8") # Assert assert isinstance(testprofile.virt_file_size, int) assert testprofile.virt_file_size == 8
def test_set_repo_os_version(): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testrepo = Repo(test_manager) testrepo.set_breed("yum") # Act utils.set_repo_os_version(testrepo, "rhel4") # Assert assert testrepo.breed == "yum" assert testrepo.os_version == "rhel4"
def test_set_os_version(): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testdistro = Distro(test_manager) testdistro.set_breed("redhat") # Act utils.set_os_version(testdistro, "rhel4") # Assert assert testdistro.breed == "redhat" assert testdistro.os_version == "rhel4"
def test_copy_single_distro_file(): # Instantiate TFTPGen class with collection_mgr parameter test_api = CobblerAPI() test_collection_mgr = CollectionManager(test_api) generator = tftpgen.TFTPGen(test_collection_mgr) # Arrange distro_file = "/code/tests/test_data/dummy_initramfs" distro_dir = "/srv/tftpboot/images/" symlink_ok = True initramfs_dst_path = "/srv/tftpboot/images/dummy_initramfs" # Act generator.copy_single_distro_file(distro_file, distro_dir, symlink_ok) # Assert assert os.path.isfile(initramfs_dst_path)
def test_kopts_overwrite(): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) test_distro = Distro(test_manager) test_distro.set_breed("suse") test_distro.name = "kopts_test_distro" test_profile = Profile(test_manager) test_profile.distro = test_distro.name test_system = System(test_manager) test_system.name = "kopts_test_system" kopts = {"textmode": False, "text": True} # Act utils.kopts_overwrite(test_system, test_distro, kopts, test_api.settings()) # Assert assert "textmode" in kopts assert "info" in kopts
def test_copy_bootloaders(tmpdir): # Instantiate TFTPGen class with collection_mgr parameter test_api = CobblerAPI() test_collection_mgr = CollectionManager(test_api) generator = tftpgen.TFTPGen(test_collection_mgr) # Arrange ## Create temporary bootloader files using tmpdir fixture file_contents = "I am a bootloader" sub_path = tmpdir.mkdir("loaders") sub_path.join("bootloader1").write(file_contents) sub_path.join("bootloader2").write(file_contents) ## Copy temporary bootloader files from tmpdir to expected source directory for file in glob.glob(str(sub_path + "/*")): bootloader_src = "/var/lib/cobbler/loaders/" shutil.copy(file, bootloader_src + file.split("/")[-1]) # Act generator.copy_bootloaders("/srv/tftpboot") # Assert assert os.path.isfile("/srv/tftpboot/bootloader1") assert os.path.isfile("/srv/tftpboot/bootloader2")