blob: a0e59e6bb02cbbd9c60efa234a3c4975c0fe22d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# Copyright (C) 2013 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
import pytest
from virtinst import Guest
from virtinst import OSDB
from virtinst import xmlutil
from virtinst.install import urldetect
from tests import utils
##################
# Test osdict.py #
##################
def test_list_os():
OSDB.list_os()
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
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)
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
def test_kernel_url():
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()
assert _c("rhel7-unknown") == "inst.repo"
assert _c("rhel6-unknown") == "method"
assert _c("fedora-rawhide") == "inst.repo"
assert _c("fedora20") == "inst.repo"
assert _c("generic") is None
assert _c("win10") is None
assert _c("sle15") == "install"
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
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")
|