Example #1
0
def test_drivers():
    win7 = OSDB.lookup_os("win7")
    generic = OSDB.lookup_os("generic")
    assert generic.supports_unattended_drivers("x86_64") is False
    assert win7.supports_unattended_drivers("x86_64") is True
    assert win7.supports_unattended_drivers("fakearch") is False
    assert win7.get_pre_installable_drivers_location("x86_64")
Example #2
0
 def test_drivers(self):
     win7 = OSDB.lookup_os("win7")
     generic = OSDB.lookup_os("generic")
     self.assertFalse(generic.supports_unattended_drivers("x86_64"))
     self.assertTrue(win7.supports_unattended_drivers("x86_64"))
     self.assertFalse(win7.supports_unattended_drivers("fakearch"))
     self.assertTrue(win7.get_pre_installable_drivers_location("x86_64"))
Example #3
0
def test_tree_url():
    f26 = OSDB.lookup_os("fedora26")
    f29 = OSDB.lookup_os("fedora29")
    winxp = OSDB.lookup_os("winxp")

    # Valid tree URL
    assert "fedoraproject.org" in f26.get_location("x86_64")

    # Most generic tree URL
    assert "Everything" in f29.get_location("x86_64")

    # Specific tree
    assert "Server" in f29.get_location("x86_64", "jeos")
    assert "Workstation" in f29.get_location("x86_64", "desktop")

    # Has tree URLs, but none for arch
    try:
        f26.get_location("ia64")
        raise AssertionError("Expected failure")
    except RuntimeError as e:
        assert "ia64" in str(e)

    # Has no tree URLs
    try:
        winxp.get_location("x86_64")
        raise AssertionError("Expected failure")
    except RuntimeError as e:
        assert str(e).endswith("URL location")

    # Trigger an error path for code coverage
    assert OSDB.guess_os_by_tree(utils.TESTDIR) is None
Example #4
0
    def test_list_os(self):
        full_list = OSDB.list_os()
        pref_list = OSDB.list_os(typename="linux", sortpref=["fedora", "rhel"])
        support_list = OSDB.list_os(only_supported=True)

        assert full_list[0] is not pref_list[0]
        assert len(full_list) > len(support_list)
        assert len(OSDB.list_os(typename="generic")) == 1

        # Verify that sort order actually worked
        found_fedora = False
        found_rhel = False
        for idx, osobj in enumerate(pref_list[:]):
            if osobj.name.startswith("fedora"):
                found_fedora = True
                continue

            for osobj2 in pref_list[idx:]:
                if osobj2.name.startswith("rhel"):
                    found_rhel = True
                    continue
                break
            break

        assert found_fedora and found_rhel
Example #5
0
def test_recommended_resources():
    conn = utils.URIs.open_testdefault_cached()
    guest = Guest(conn)
    res = OSDB.lookup_os("generic").get_recommended_resources()
    assert res.get_recommended_ram(guest.os.arch) is None

    res = OSDB.lookup_os("fedora21").get_recommended_resources()
    assert res.get_recommended_ncpus(guest.os.arch) == 2
Example #6
0
    def test_recommended_resources(self):
        conn = utils.URIs.open_testdefault_cached()
        guest = Guest(conn)
        res = OSDB.lookup_os("generic").get_recommended_resources()
        self.assertEqual(res.get_recommended_ram(guest.os.arch), None)

        res = OSDB.lookup_os("fedora21").get_recommended_resources()
        self.assertEqual(res.get_recommended_ncpus(guest.os.arch), 2)
Example #7
0
    def test_drivers(self):
        win7 = OSDB.lookup_os("win7")
        generic = OSDB.lookup_os("generic")
        self.assertFalse(generic.supports_unattended_drivers("x86_64"))
        self.assertTrue(win7.supports_unattended_drivers("x86_64"))
        self.assertFalse(win7.supports_unattended_drivers("fakearch"))
        self.assertTrue(win7.get_pre_installable_drivers_location("x86_64"))

        # Just call this for code coverage. Values differ by osinfo-db version
        win7.get_post_installable_drivers_location("x86_64")
Example #8
0
    def test_recommended_resources(self):
        conn = utils.open_testdriver()
        guest = conn.caps.lookup_virtinst_guest()
        assert not OSDB.lookup_os("generic").get_recommended_resources(guest)

        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 2

        guest.type = "qemu"
        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 1
Example #9
0
    def test_recommended_resources(self):
        conn = utils.URIs.open_testdefault_cached()
        guest = Guest(conn)
        assert not OSDB.lookup_os("generic").get_recommended_resources(guest)

        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 2

        guest.type = "qemu"
        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 1
Example #10
0
    def test_recommended_resources(self):
        conn = utils.URIs.open_testdefault_cached()
        guest = Guest(conn)
        assert not OSDB.lookup_os("generic").get_recommended_resources(guest)

        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 2

        guest.type = "qemu"
        res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
        assert res["n-cpus"] == 1
Example #11
0
    def test_osdict_types_ro(self):
        # 'types' should rarely be altered, this check will make
        # doubly sure that a new type isn't accidentally added
        approved_types = OSDB.list_types()

        for osobj in OSDB.list_os():
            if osobj.get_typename() not in approved_types:
                raise AssertionError("OS entry '%s' has OS type '%s'.\n"
                    "The type list should NOT be extended without a lot of "
                    "thought, please make sure you know what you are doing." %
                    (osobj.name, osobj.get_typename()))
Example #12
0
def _sanitize_osdict_name(detectdistro):
    if detectdistro in ["none", "None", None]:
        return None

    if detectdistro == "testsuite-fedora-rawhide":
        # Special value we use in the test suite to always return the latest
        # fedora when checking rawhide URL
        return OSDB.latest_fedora_version()

    return detectdistro
Example #13
0
    def test_tree_url(self):
        f26 = OSDB.lookup_os("fedora26")
        winxp = OSDB.lookup_os("winxp")

        # Valid tree URL
        assert "fedoraproject.org" in f26.get_location("x86_64")

        # Has tree URLs, but none for arch
        try:
            f26.get_location("ia64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "ia64" in str(e)

        # Has no tree URLs
        try:
            winxp.get_location("x86_64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert str(e).endswith("URL location")
Example #14
0
    def test_tree_url(self):
        f26 = OSDB.lookup_os("fedora26")
        winxp = OSDB.lookup_os("winxp")

        # Valid tree URL
        assert "fedoraproject.org" in f26.get_location("x86_64")

        # Has tree URLs, but none for arch
        try:
            f26.get_location("ia64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "ia64" in str(e)

        # Has no tree URLs
        try:
            winxp.get_location("x86_64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert str(e).endswith("URL location")
Example #15
0
    def test_get_script(self):
        dos = OSDB.lookup_os("msdos6.22")
        winxp = OSDB.lookup_os("winxp")

        # No install scripts at all
        try:
            dos.get_install_script("desktop")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "does not support unattended installation." in str(e)

        # No profile foobar
        try:
            winxp.get_install_script("foobar")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "foobar" in str(e)

        script = winxp.get_install_script("desktop")
        self.assertTrue(bool(script))
Example #16
0
    def test_get_script(self):
        dos = OSDB.lookup_os("msdos6.22")
        winxp = OSDB.lookup_os("winxp")

        # No install scripts at all
        try:
            dos.get_install_script("desktop")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "does not support unattended installation." in str(e)

        # No profile foobar
        try:
            winxp.get_install_script("foobar")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "foobar" in str(e)

        script = winxp.get_install_script("desktop")
        self.assertTrue(bool(script))
Example #17
0
def test_urldetct_matching_distros():
    # pylint: disable=protected-access
    allstores = urldetect._build_distro_list(OSDB.lookup_os("generic"))

    seen_distro = []
    for store in allstores:
        for distro in store.matching_distros:
            if distro in seen_distro:
                raise xmlutil.DevError(
                    "store=%s has conflicting matching_distro=%s " %
                    (store.PRETTY_NAME, distro))
            seen_distro.append(distro)
Example #18
0
def _sanitize_osdict_name(detectdistro):
    """
    Try to handle working with out of date osinfo-db data. Like if
    checking distro FedoraXX but osinfo-db latest Fedora is
    FedoraXX-1, convert to use that
    """
    if not detectdistro:
        return detectdistro

    if detectdistro == "testsuite-fedora-rawhide":
        # Special value we use in the test suite to always return the latest
        # fedora when checking rawhide URL
        return OSDB.latest_fedora_version()

    if re.match("fedora[0-9]+", detectdistro):
        if not OSDB.lookup_os(detectdistro):
            ret = OSDB.latest_fedora_version()
            print("\nConverting detectdistro=%s to latest value=%s" %
                  (detectdistro, ret))
            return ret

    return detectdistro
Example #19
0
    def test_tree_url(self):
        f26 = OSDB.lookup_os("fedora26")
        winxp = OSDB.lookup_os("winxp")

        # Valid tree URL
        assert "fedoraproject.org" in f26.get_location("x86_64")

        # Has tree URLs, but none for arch
        try:
            f26.get_location("ia64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert "ia64" in str(e)

        # Has no tree URLs
        try:
            winxp.get_location("x86_64")
            raise AssertionError("Expected failure")
        except RuntimeError as e:
            assert str(e).endswith("URL location")

        # Trigger an error path for code coverage
        self.assertEqual(OSDB.guess_os_by_tree(os.getcwd()), None)
Example #20
0
 def _c(name):
     osobj = OSDB.lookup_os(name)
     if not osobj:
         pytest.skip("osinfo-db doesn't have '%s'" % name)
     return osobj.get_kernel_url_arg()
Example #21
0
 def test_list_os(self):
     OSDB.list_os()
Example #22
0
def test_related_to():
    # pylint: disable=protected-access
    win10 = OSDB.lookup_os("win10")
    assert win10._is_related_to("winxp") is True
    assert win10._is_related_to("win10") is True
    assert win10._is_related_to("fedora26") is False
Example #23
0
 def test_related_to(self):
     # pylint: disable=protected-access
     win10 = OSDB.lookup_os("win10")
     self.assertTrue(win10._is_related_to("winxp"))
     self.assertTrue(win10._is_related_to("win10"))
     self.assertTrue(win10._is_related_to("fedora26") is False)
Example #24
0
def test_list_os():
    OSDB.list_os()