virt-manager/tests/osdict.py
Daniel P. Berrangé d52d9885c8 Redesign OS distro selection UI to be faster to use
The current OS distro selection UI is fairly cumbersome to use. First
you need to decide on a variant, then decide a distro and then look for
the version you want. The list is filtered by default so only a subset
of OS are displayed. So for less common distros you'll then need to
start again and tell it to show all OS to try to find the one you want.

The core problem is that we have an incredibly large list and want to
make it easy for the user to find a specific entry. The modern UI
paradigm for this problem is to provide interactive search with
live updated results. The current UI does provide an interactive search
facility on the OS version results, but you still have to first select a
variant to be able to use the search which is unhelpful.

This patch attempts to better apply the search UI design to the OS selection
problem. We get rid of the notion of variants, distros and version, and
provide a single text entry box in which the user can type a few letters
of the OS name. As they type, a popover displays the matching results
filtered on OS name. By default end of life OS will be hidden, so in
general there will only be a small handful of results left after just
typing a few characters. This makes it very quick to find and select the
desired OS, without needing to provide a mutli-step navigation hierarchy.

https://bugzilla.redhat.com/show_bug.cgi?id=1464306

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

(crobinso: fix some pylint)
2018-05-01 11:31:39 -04:00

48 lines
1.6 KiB
Python

# 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 unittest
from virtinst import OSDB
from tests import utils
class TestOSDB(unittest.TestCase):
"""
Test osdict/OSDB
"""
def test_osdict_aliases_ro(self):
aliases = getattr(OSDB, "_aliases")
if len(aliases) != 42:
raise AssertionError(_("OSDB._aliases changed size. It "
"should never be extended, since it is only for back "
"compat with pre-libosinfo osdict.py"))
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()))
def test_recommended_resources(self):
conn = utils.URIs.open_testdefault_cached()
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