|
Packit Service |
21c75c |
# -*- coding: utf-8 -*-
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
# Copyright (C) 2012-2018 Red Hat, Inc.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
# This copyrighted material is made available to anyone wishing to use,
|
|
Packit Service |
21c75c |
# modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit Service |
21c75c |
# the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit Service |
21c75c |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
21c75c |
# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit Service |
21c75c |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit Service |
21c75c |
# Public License for more details. You should have received a copy of the
|
|
Packit Service |
21c75c |
# GNU General Public License along with this program; if not, write to the
|
|
Packit Service |
21c75c |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
21c75c |
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit Service |
21c75c |
# source code or documentation are not subject to the GNU General Public
|
|
Packit Service |
21c75c |
# License and may only be used or replicated with the express permission of
|
|
Packit Service |
21c75c |
# Red Hat, Inc.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
from __future__ import absolute_import
|
|
Packit Service |
21c75c |
from __future__ import unicode_literals
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import itertools
|
|
Packit Service |
21c75c |
import logging
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import dnf.exceptions
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import tests.support
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class CommonTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests common to any 'multilib_policy' and 'best'.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The test fixture consists of a dnf.Base instance that:
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.x86_64" (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.i686" (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "trampoline-2.1-1.noarch" that contains
|
|
Packit Service |
21c75c |
"/all/be/there", provides "splendid > 2.0" and "php(a/b)" (The package
|
|
Packit Service |
21c75c |
can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "mrkite-2-0.x86_64" (The package can be installed
|
|
Packit Service |
21c75c |
together with the package "trampoline".)
|
|
Packit Service |
21c75c |
- contains a package "mrkite-k-h-1-1.x86_64" (The package can be
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-0.src"
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-2.x86_64" (The package cannot be
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "librita-1-1.x86_64" (The package is already
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "hole-1-2.x86_64" (The package can be installed as an
|
|
Packit Service |
21c75c |
upgrade.)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'third_party', 'broken_deps']
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_arch_glob(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg specification can contain an architecture glob."""
|
|
Packit Service |
21c75c |
self.base.install("lotus.*6*")
|
|
Packit Service |
21c75c |
installed = self.installed_removed(self.base)[0]
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
['lotus-3-17.i686',
|
|
Packit Service |
21c75c |
'lotus-3-17.x86_64'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_filename_glob(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by fname glob."""
|
|
Packit Service |
21c75c |
self.base.install("*/there")
|
|
Packit Service |
21c75c |
(installed, _) = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
('trampoline-2.1-1.noarch',))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.install("/all/*/there")
|
|
Packit Service |
21c75c |
(installed, _) = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
('trampoline-2.1-1.noarch',))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name(self):
|
|
Packit Service |
21c75c |
"""Test that the package to be installed can be specified by name."""
|
|
Packit Service |
21c75c |
self.base.install("mrkite")
|
|
Packit Service |
21c75c |
available = self.base.sack.query().available()
|
|
Packit Service |
21c75c |
expected = available.filter(name=["mrkite", "trampoline"]).run()
|
|
Packit Service |
21c75c |
# ensure sanity of the test (otherwise it would pass no matter what):
|
|
Packit Service |
21c75c |
self.assertEqual(len(expected), 2)
|
|
Packit Service |
21c75c |
new_set = self.base.sack.query().installed() + expected
|
|
Packit Service |
21c75c |
self.assertResult(self.base, new_set)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name_glob(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by name glob."""
|
|
Packit Service |
21c75c |
self.base.install("mrkite*")
|
|
Packit Service |
21c75c |
installed = self.installed_removed(self.base)[0]
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
['mrkite-2-0.x86_64',
|
|
Packit Service |
21c75c |
'mrkite-k-h-1-1.x86_64',
|
|
Packit Service |
21c75c |
'trampoline-2.1-1.noarch'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name_glob_exclude(self):
|
|
Packit Service |
21c75c |
"""Test that glob excludes play well with glob installs."""
|
|
Packit Service |
21c75c |
subj_ex = dnf.subject.Subject('*-1')
|
|
Packit Service |
21c75c |
pkgs_ex = subj_ex.get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
self.base.sack.add_excludes(pkgs_ex)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.install('mrkite*')
|
|
Packit Service |
21c75c |
(installed, _) = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
['mrkite-2-0.x86_64',
|
|
Packit Service |
21c75c |
'trampoline-2.1-1.noarch'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_nevra(self):
|
|
Packit Service |
21c75c |
"""Test that the package to be installed can be specified by NEVRA."""
|
|
Packit Service |
21c75c |
self.base.install("lotus-3-17.i686")
|
|
Packit Service |
21c75c |
lotus, = dnf.subject.Subject('lotus-3-17.i686').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
new_set = self.base.sack.query().installed() + [lotus]
|
|
Packit Service |
21c75c |
self.assertResult(self.base, new_set)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_provide_slash(self):
|
|
Packit Service |
21c75c |
self.base.install("php(a/b)")
|
|
Packit Service |
21c75c |
(installed, _) = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, installed),
|
|
Packit Service |
21c75c |
('trampoline-2.1-1.noarch',))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_provide_version(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be spec. by provide ver."""
|
|
Packit Service |
21c75c |
self.base.install('splendid > 2.0')
|
|
Packit Service |
21c75c |
self.assertGreater(self.base._goal.req_length(), 0)
|
|
Packit Service |
21c75c |
trampoline = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
name="trampoline")
|
|
Packit Service |
21c75c |
new_set = self.base.sack.query().installed() + trampoline.run()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, new_set)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_package_install_conflict(self):
|
|
Packit Service |
21c75c |
"""Test that a conflicting package cannot be installed."""
|
|
Packit Service |
21c75c |
p = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
nevra='pepper-20-2.x86_64')[0]
|
|
Packit Service |
21c75c |
self.assertEqual(1, self.base.package_install(p))
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.DepsolveError):
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_package_install_installed(self):
|
|
Packit Service |
21c75c |
"""Test that nothing changes if an installed package matches."""
|
|
Packit Service |
21c75c |
p = self.base.sack.query().available()._nevra("librita-1-1.x86_64")[0]
|
|
Packit Service |
21c75c |
with tests.support.mock.patch('logging.Logger.warning'):
|
|
Packit Service |
21c75c |
self.base.package_install(p)
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
self.assertEmpty(self.base._goal.list_reinstalls())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.history.close()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.package_reinstall(p)
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
self.assertLength(self.base._goal.list_reinstalls(), 1)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_package_install_upgrade(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be an upgrade."""
|
|
Packit Service |
21c75c |
p = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
nevra='hole-1-2.x86_64')[0]
|
|
Packit Service |
21c75c |
self.assertEqual(1, self.base.package_install(p))
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertIn(p, installed)
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
removed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().installed().filter(name='hole')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_pkg_install_installable(self):
|
|
Packit Service |
21c75c |
"""Test that the package to be installed can be a package instance."""
|
|
Packit Service |
21c75c |
p = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
nevra='lotus-3-17.x86_64')[0]
|
|
Packit Service |
21c75c |
self.assertEqual(1, self.base.package_install(p))
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
self.assertEqual(1, len(self.base._goal.list_installs()))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_pkg_install_installonly(self):
|
|
Packit Service |
21c75c |
"""Test that installonly packages are installed, not upgraded."""
|
|
Packit Service |
21c75c |
self.base.conf.installonlypkgs += ['hole']
|
|
Packit Service |
21c75c |
p = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
nevra='hole-1-2.x86_64')[0]
|
|
Packit Service |
21c75c |
self.assertEqual(1, self.base.package_install(p))
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertIn(p, installed)
|
|
Packit Service |
21c75c |
self.assertFalse(
|
|
Packit Service |
21c75c |
set(removed) &
|
|
Packit Service |
21c75c |
set(self.base.sack.query().installed().filter(name='hole')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MultilibAllTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests for multilib_policy='all'.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The test fixture consists of a dnf.Base instance that:
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
- has conf.multilib_policy == "all"
|
|
Packit Service |
21c75c |
- has conf.best == False
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-2" (The package cannot be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-16.x86_64" that contains "/usr/lib*/liblot*"
|
|
Packit Service |
21c75c |
in a "main" repository (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-16.i686" that contains "/usr/lib*/liblot*" in
|
|
Packit Service |
21c75c |
the "main" repository (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "librita-1-1.x86_64" (The package is already
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "hole-1-2.x86_64" (The package can be installed as an
|
|
Packit Service |
21c75c |
upgrade.)
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-0.src"
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-0.x86_64" (The package is already
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains nothing that matches "not-available"
|
|
Packit Service |
21c75c |
- contains a package that provides "henry(the_horse)" (The package can be
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.x86_64" not in a "main" repository (The
|
|
Packit Service |
21c75c |
package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.i686" not in the "main" repository (The
|
|
Packit Service |
21c75c |
package can be installed.)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'third_party', 'broken_deps']
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
super(MultilibAllTest, self).setUp()
|
|
Packit Service |
21c75c |
self.base.conf.multilib_policy = "all"
|
|
Packit Service |
21c75c |
assert self.base.conf.best is False
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_conflict(self):
|
|
Packit Service |
21c75c |
"""Test that the exception is raised if the package conflicts."""
|
|
Packit Service |
21c75c |
self.base.install('pepper-20-2')
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.DepsolveError):
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_filename(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by filename."""
|
|
Packit Service |
21c75c |
self.base.install("/usr/lib*/liblot*")
|
|
Packit Service |
21c75c |
inst, _ = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(
|
|
Packit Service |
21c75c |
map(str, inst), ['lotus-3-16.x86_64', 'lotus-3-16.i686'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_installed(self):
|
|
Packit Service |
21c75c |
"""Test that nothing changes if an installed package matches."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.base.install('librita')
|
|
Packit Service |
21c75c |
self.assertEqual(self.base._goal.req_length(), 0)
|
|
Packit Service |
21c75c |
self.assertIn(
|
|
Packit Service |
21c75c |
'Package librita-1-1.x86_64 is already installed.',
|
|
Packit Service |
21c75c |
stdout.getvalue())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_installonly(self):
|
|
Packit Service |
21c75c |
"""Test that installonly packages are installed, not upgraded."""
|
|
Packit Service |
21c75c |
self.base.conf.installonlypkgs += ['hole']
|
|
Packit Service |
21c75c |
self.base.install('hole-1-2')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
installed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().available()._nevra('hole-1-2.x86_64')))
|
|
Packit Service |
21c75c |
self.assertEmpty(removed)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_multilib(self):
|
|
Packit Service |
21c75c |
"""Test that pkgs for all architectures are installed if available."""
|
|
Packit Service |
21c75c |
cnt = self.base.install("lotus")
|
|
Packit Service |
21c75c |
self.assertEqual(cnt, 2)
|
|
Packit Service |
21c75c |
installed = self.installed_removed(self.base)[0]
|
|
Packit Service |
21c75c |
self.assertLessEqual(
|
|
Packit Service |
21c75c |
set(installed),
|
|
Packit Service |
21c75c |
set(self.base.sack.query().available().filter(name='lotus')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name_choice(self):
|
|
Packit Service |
21c75c |
"""Test that the matching pkg that can be installed is installed."""
|
|
Packit Service |
21c75c |
# Don't install the SRPM.
|
|
Packit Service |
21c75c |
self.base.sack.add_excludes(
|
|
Packit Service |
21c75c |
dnf.subject.Subject('pepper.src').get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.base.install('pepper')
|
|
Packit Service |
21c75c |
self.assertEqual(self.base._goal.req_length(), 0)
|
|
Packit Service |
21c75c |
self.assertIn(
|
|
Packit Service |
21c75c |
'Package pepper-20-0.x86_64 is already installed.',
|
|
Packit Service |
21c75c |
stdout.getvalue())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_nonexistent(self):
|
|
Packit Service |
21c75c |
"""Test that the exception is raised if no package matches."""
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.MarkingError) as context:
|
|
Packit Service |
21c75c |
self.base.install('not-available')
|
|
Packit Service |
21c75c |
self.assertEqual(context.exception.pkg_spec, 'not-available')
|
|
Packit Service |
21c75c |
installed_pkgs = self.base.sack.query().installed().run()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, installed_pkgs)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_provide(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by provide."""
|
|
Packit Service |
21c75c |
self.base.install("henry(the_horse)")
|
|
Packit Service |
21c75c |
self.assertGreater(self.base._goal.req_length(), 0)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_reponame(self):
|
|
Packit Service |
21c75c |
"""Test whether packages are filtered by the reponame."""
|
|
Packit Service |
21c75c |
result = itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed(),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('lotus-3-16').get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.install('lotus', reponame='main')
|
|
Packit Service |
21c75c |
self.assertResult(self.base, result)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
assert dnf.subject.Subject('lotus-3-17').get_best_query(self.base.sack), \
|
|
Packit Service |
21c75c |
('the base must contain packages a package in another repo '
|
|
Packit Service |
21c75c |
'which matches the pattern but is preferred, otherwise the '
|
|
Packit Service |
21c75c |
'test makes no sense')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_upgrade(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be an upgrade."""
|
|
Packit Service |
21c75c |
self.base.install('hole-1-2')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
installed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().available()._nevra('hole-1-2.x86_64')))
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
removed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().installed().filter(name='hole')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class MultilibBestTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests for multilib_policy='best'.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The test fixture consists of a dnf.Base instance that:
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
- has conf.multilib_policy == "best"
|
|
Packit Service |
21c75c |
- has conf.best == False
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-2" (The package cannot be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-16.x86_64" that contains "/usr/lib*/liblot*"
|
|
Packit Service |
21c75c |
in a "main" repository (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-16.i686" that contains "/usr/lib*/liblot*"
|
|
Packit Service |
21c75c |
in the "main" repository (The package can be installed.)
|
|
Packit Service |
21c75c |
- contains nothing that matches "/not/exist/"
|
|
Packit Service |
21c75c |
- contains a package "librita-1-1.x86_64" (The package is already
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains a package "hole-1-2.x86_64" (The package can be installed as an
|
|
Packit Service |
21c75c |
upgrade.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.x86_64" not in the "main" repository (The
|
|
Packit Service |
21c75c |
package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-0.src"
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-0.x86_64" (The package is already
|
|
Packit Service |
21c75c |
installed.)
|
|
Packit Service |
21c75c |
- contains nothing that matches "not-available"
|
|
Packit Service |
21c75c |
- contains a package "trampoline" that provides "henry(the_horse)" (The
|
|
Packit Service |
21c75c |
package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "lotus-3-17.i686" not in the "main" repository (The
|
|
Packit Service |
21c75c |
package can be installed.)
|
|
Packit Service |
21c75c |
- contains a package "hole-1-1.x86_64" (The package is already installed
|
|
Packit Service |
21c75c |
and is not available.)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'third_party', 'broken_deps']
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
super(MultilibBestTest, self).setUp()
|
|
Packit Service |
21c75c |
self.installed = self.base.sack.query().installed().run()
|
|
Packit Service |
21c75c |
self.assertEqual(self.base.conf.multilib_policy, "best")
|
|
Packit Service |
21c75c |
assert self.base.conf.best is False
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_conflict(self):
|
|
Packit Service |
21c75c |
"""Test that the exception is raised if the package conflicts."""
|
|
Packit Service |
21c75c |
self.base.install('pepper-20-2')
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.DepsolveError):
|
|
Packit Service |
21c75c |
self.base.resolve()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_filename(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by filename."""
|
|
Packit Service |
21c75c |
self.base.install("/usr/lib*/liblot*")
|
|
Packit Service |
21c75c |
inst, _ = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertCountEqual(map(str, inst), ['lotus-3-16.x86_64'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.MarkingError,
|
|
Packit Service |
21c75c |
self.base.install, "/not/exist/")
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_installed(self):
|
|
Packit Service |
21c75c |
"""Test that nothing changes if an installed package matches."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.base.install('librita')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertEmpty(installed)
|
|
Packit Service |
21c75c |
self.assertEmpty(removed)
|
|
Packit Service |
21c75c |
self.assertIn(
|
|
Packit Service |
21c75c |
'Package librita-1-1.x86_64 is already installed.',
|
|
Packit Service |
21c75c |
stdout.getvalue())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_installonly(self):
|
|
Packit Service |
21c75c |
"""Test that installonly packages are installed, not upgraded."""
|
|
Packit Service |
21c75c |
self.base.conf.installonlypkgs += ['hole']
|
|
Packit Service |
21c75c |
self.base.install('hole-1-2')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
installed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().available()._nevra('hole-1-2.x86_64')))
|
|
Packit Service |
21c75c |
self.assertEmpty(removed)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_multilib(self):
|
|
Packit Service |
21c75c |
"""Test that a pkg for only one architecture are installed."""
|
|
Packit Service |
21c75c |
cnt = self.base.install("lotus")
|
|
Packit Service |
21c75c |
self.assertEqual(cnt, 1)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
new_package, = dnf.subject.Subject('lotus-3-17.x86_64').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
new_set = self.installed + [new_package]
|
|
Packit Service |
21c75c |
self.assertResult(self.base, new_set)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name_choice(self):
|
|
Packit Service |
21c75c |
"""Test that the matching pkg that can be installed is installed."""
|
|
Packit Service |
21c75c |
# Don't install the SRPM.
|
|
Packit Service |
21c75c |
self.base.sack.add_excludes(
|
|
Packit Service |
21c75c |
dnf.subject.Subject('pepper.src').get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.base.install('pepper')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertEmpty(installed | removed)
|
|
Packit Service |
21c75c |
self.assertIn(
|
|
Packit Service |
21c75c |
'Package pepper-20-0.x86_64 is already installed.',
|
|
Packit Service |
21c75c |
stdout.getvalue())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_nonexistent(self):
|
|
Packit Service |
21c75c |
"""Test that the exception is raised if no package matches."""
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.MarkingError) as context:
|
|
Packit Service |
21c75c |
self.base.install('not-available')
|
|
Packit Service |
21c75c |
self.assertEqual(context.exception.pkg_spec, 'not-available')
|
|
Packit Service |
21c75c |
installed_pkgs = self.base.sack.query().installed().run()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, installed_pkgs)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_provide(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be specified by provide."""
|
|
Packit Service |
21c75c |
self.base.install("henry(the_horse)")
|
|
Packit Service |
21c75c |
self.assertGreater(self.base._goal.req_length(), 0)
|
|
Packit Service |
21c75c |
trampoline = self.base.sack.query().available().filter(
|
|
Packit Service |
21c75c |
name="trampoline")
|
|
Packit Service |
21c75c |
new_set = self.installed + trampoline.run()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, new_set)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_reponame(self):
|
|
Packit Service |
21c75c |
"""Test whether packages are filtered by the reponame."""
|
|
Packit Service |
21c75c |
result = itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed(),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('lotus-3-16.x86_64')
|
|
Packit Service |
21c75c |
.get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.base.install('lotus', reponame='main')
|
|
Packit Service |
21c75c |
self.assertResult(self.base, result)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
assert dnf.subject.Subject('lotus-3-17.x86_64').get_best_query(self.base.sack), \
|
|
Packit Service |
21c75c |
('the base must contain packages a package in another repo '
|
|
Packit Service |
21c75c |
'which matches the pattern but is preferred, otherwise the '
|
|
Packit Service |
21c75c |
'test makes no sense')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_unavailable(self):
|
|
Packit Service |
21c75c |
"""Test that nothing changes if an unavailable package matches."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
cnt = self.base.install('hole')
|
|
Packit Service |
21c75c |
self.assertEqual(cnt, 1)
|
|
Packit Service |
21c75c |
installed_pkgs = self.base.sack.query().installed().run()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, installed_pkgs)
|
|
Packit Service |
21c75c |
self.assertIn(
|
|
Packit Service |
21c75c |
'Package hole-1-1.x86_64 is already installed.',
|
|
Packit Service |
21c75c |
stdout.getvalue())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_upgrade(self):
|
|
Packit Service |
21c75c |
"""Test that the pkg to be installed can be an upgrade."""
|
|
Packit Service |
21c75c |
self.base.install('hole-1-2')
|
|
Packit Service |
21c75c |
installed, removed = self.installed_removed(self.base)
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
installed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().available()._nevra('hole-1-2.x86_64')))
|
|
Packit Service |
21c75c |
self.assertGreaterEqual(
|
|
Packit Service |
21c75c |
removed,
|
|
Packit Service |
21c75c |
set(self.base.sack.query().installed().filter(name='hole')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class BestTrueTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests for best=True.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The test fixture consists of a dnf.Base instance that:
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
- has conf.best == True
|
|
Packit Service |
21c75c |
- contains a package "pepper-20-2" (The package cannot be installed.)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['broken_deps']
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
super(BestTrueTest, self).setUp()
|
|
Packit Service |
21c75c |
self.base.conf.best = True
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_install_name_choice(self):
|
|
Packit Service |
21c75c |
"""Test that the latest version of the matching pkg is installed."""
|
|
Packit Service |
21c75c |
with tests.support.mock.patch('logging.Logger.warning'):
|
|
Packit Service |
21c75c |
self.base.install('pepper')
|
|
Packit Service |
21c75c |
with self.assertRaises(dnf.exceptions.DepsolveError):
|
|
Packit Service |
21c75c |
self.base.resolve()
|