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_object_creation(): # Arrange test_api = CobblerAPI() # Act profile = Profile(test_api) # Arrange assert isinstance(profile, Profile)
def test_make_clone(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act result = profile.make_clone() # Assert assert result != profile
def test_menu(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.menu = "" # Assert assert profile.menu == ""
def test_proxy(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.proxy = "" # Assert assert profile.proxy == ""
def test_filename(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.filename = "<<inherit>>" # Assert assert profile.filename == "<<inherit>>"
def test_repos(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.repos = "" # Assert assert profile.repos == []
def test_autoinstall(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.autoinstall = "" # Assert assert profile.autoinstall == ""
def test_name_servers_search(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.name_servers_search = "" # Assert assert profile.name_servers_search is None
def test_virt_path(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.virt_path = "" # Assert assert profile.virt_path == ""
def test_distro(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.distro = "" # Assert assert profile.distro is None
def test_name_servers(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.name_servers = [] # Assert assert profile.name_servers == []
def test_redhat_management_key(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.redhat_management_key = "" # Assert assert profile.redhat_management_key == ""
def test_parent(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.parent = "" # Assert assert profile.parent is None
def test_next_server_v6(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.next_server_v6 = "" # Assert assert profile.next_server_v6 == ""
def test_server(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.server = "" # Assert assert profile.server == "<<inherit>>"
def test_dhcp_tag(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.dhcp_tag = "" # Assert assert profile.dhcp_tag == ""
def test_boot_loaders(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.boot_loaders = "" # Assert assert profile.boot_loaders == []
def test_virt_bridge(): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act profile.virt_bridge = "" # Assert # This is the default from the settings assert profile.virt_bridge == "xenbr0"
def test_virt_ram(value, expected_exception): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.virt_ram = value # Assert assert profile.virt_ram == int(value)
def test_enable_ipxe(value, expected_exception): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.enable_ipxe = value # Assert assert profile.enable_ipxe is value
def test_virt_cpus(value, expected_exception, expected_result): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.virt_cpus = value # Assert assert profile.virt_cpus == expected_result
def test_set_virt_disk_driver(test_driver, expected_result, test_raise): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testprofile = Profile(test_manager) # Act with test_raise: utils.set_virt_disk_driver(testprofile, test_driver) # Assert assert testprofile.virt_disk_driver == expected_result
def test_enable_menu(value, expected_exception): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.enable_menu = value # Assert assert isinstance(profile.enable_menu, bool) assert profile.enable_menu or not profile.enable_menu
def test_virt_auto_boot(value, expected_exception): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.virt_auto_boot = value # Assert assert isinstance(profile.virt_auto_boot, bool) assert profile.virt_auto_boot or not profile.virt_auto_boot
def test_set_repos(): # Arrange test_api = CobblerAPI() test_manager = CollectionManager(test_api) testprofile = Profile(test_manager) # Act # TODO: Test this also with the bypass check utils.set_repos(testprofile, "testrepo1 testrepo2", bypass_check=True) # Assert assert testprofile.repos == ["testrepo1", "testrepo2"]
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_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, bool) assert testprofile.virt_auto_boot is True or testprofile.virt_auto_boot is False
def test_virt_type(value, expected_exception): # Arrange test_api = CobblerAPI() profile = Profile(test_api) # Act with expected_exception: profile.virt_type = value # Assert if isinstance(value, str): assert profile.virt_type.value == value else: assert profile.virt_type == value