def test_generate_profile(self, api, create_kernel_initrd, fk_kernel, fk_initrd, cleanup_items): # Arrange folder = create_kernel_initrd(fk_kernel, fk_initrd) kernel_path = os.path.join(folder, fk_kernel) initrd_path = os.path.join(folder, fk_initrd) test_distro = Distro(api) test_distro.name = "testdistro" test_distro.kernel = kernel_path test_distro.initrd = initrd_path api.add_distro(test_distro) test_profile = Profile(api) test_profile.name = "testprofile" test_profile.distro = test_distro.name api.add_profile(test_profile) blendered_data = utils.blender(api, False, test_profile) test_builder = AppendLineBuilder(test_distro.name, blendered_data) # Act result = test_builder.generate_profile("suse") # Assert # Very basic test yes but this is the expected result atm # TODO: Make tests more sophisticated assert ( result == " append initrd=testdistro.img install=http://127.0.0.1:80/cblr/links/testdistro autoyast=default.ks" )
def test_filter_system(self, api, create_kernel_initrd, fk_kernel, fk_initrd): # Arrange folder = create_kernel_initrd(fk_kernel, fk_initrd) kernel_path = os.path.join(folder, fk_kernel) initrd_path = os.path.join(folder, fk_initrd) test_distro = Distro(api) test_distro.name = "testdistro" test_distro.kernel = kernel_path test_distro.initrd = initrd_path api.add_distro(test_distro) test_profile = Profile(api) test_profile.name = "testprofile" test_profile.distro = test_distro.name api.add_profile(test_profile) test_system = System(api) test_system.name = "testsystem" test_system.profile = test_profile.name api.add_system(test_system) itemlist = [test_system.name] build_iso = NetbootBuildiso(api) expected_result = [test_system] # Act result = build_iso.filter_systems(itemlist) # Assert assert expected_result == result
def test_to_dict(): # Arrange test_api = CobblerAPI() distro = Distro(test_api) distro.name = "testdistro" test_api.add_distro(distro, save=False) profile = Profile(test_api) profile.name = "testprofile" profile.distro = distro.name # Act result = profile.to_dict() # Assert assert len(result) == 44 assert result["distro"] == "testdistro"
def test_filter_profile(self, api, create_kernel_initrd, fk_kernel, fk_initrd, cleanup_items): # Arrange folder = create_kernel_initrd(fk_kernel, fk_initrd) kernel_path = os.path.join(folder, fk_kernel) initrd_path = os.path.join(folder, fk_initrd) test_distro = Distro(api) test_distro.name = "testdistro" test_distro.kernel = kernel_path test_distro.initrd = initrd_path api.add_distro(test_distro) test_profile = Profile(api) test_profile.name = "testprofile" test_profile.distro = test_distro.name api.add_profile(test_profile) itemlist = [test_profile.name] build_iso = buildiso.BuildIso(api) expected_result = [test_profile] # Act result = build_iso.filter_profiles(itemlist) # Assert assert expected_result == result