示例#1
0
    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"
        )
示例#2
0
    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
示例#3
0
def test_distro():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.distro = ""

    # Assert
    assert profile.distro is None
示例#4
0
def test_name_servers():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.name_servers = []

    # Assert
    assert profile.name_servers == []
示例#5
0
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
示例#6
0
def test_proxy():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.proxy = ""

    # Assert
    assert profile.proxy == ""
示例#7
0
def test_redhat_management_key():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.redhat_management_key = ""

    # Assert
    assert profile.redhat_management_key == ""
示例#8
0
def test_next_server_v6():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.next_server_v6 = ""

    # Assert
    assert profile.next_server_v6 == ""
示例#9
0
def test_virt_path():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.virt_path = ""

    # Assert
    assert profile.virt_path == ""
示例#10
0
def test_repos():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.repos = ""

    # Assert
    assert profile.repos == []
示例#11
0
def test_menu():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.menu = ""

    # Assert
    assert profile.menu == ""
示例#12
0
def test_autoinstall():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.autoinstall = ""

    # Assert
    assert profile.autoinstall == ""
示例#13
0
def test_parent():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.parent = ""

    # Assert
    assert profile.parent is None
示例#14
0
def test_filename():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.filename = "<<inherit>>"

    # Assert
    assert profile.filename == "<<inherit>>"
示例#15
0
def test_make_clone():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    result = profile.make_clone()

    # Assert
    assert result != profile
示例#16
0
def test_boot_loaders():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.boot_loaders = ""

    # Assert
    assert profile.boot_loaders == []
示例#17
0
def test_server():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.server = ""

    # Assert
    assert profile.server == "<<inherit>>"
示例#18
0
def test_dhcp_tag():
    # Arrange
    test_api = CobblerAPI()
    profile = Profile(test_api)

    # Act
    profile.dhcp_tag = ""

    # Assert
    assert profile.dhcp_tag == ""
示例#19
0
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"
示例#20
0
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)
示例#21
0
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
示例#22
0
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
示例#23
0
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
示例#24
0
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
示例#25
0
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
示例#26
0
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"
示例#27
0
def test_object_creation():
    # Arrange
    test_api = CobblerAPI()

    # Act
    profile = Profile(test_api)

    # Arrange
    assert isinstance(profile, Profile)
示例#28
0
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
示例#29
0
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"]
示例#30
0
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