|
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 |
import tempfile
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import libdnf.transaction
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import dnf.cli.commands
|
|
Packit Service |
21c75c |
import dnf.cli.commands.group
|
|
Packit Service |
21c75c |
import dnf.cli.commands.install
|
|
Packit Service |
21c75c |
import dnf.cli.commands.reinstall
|
|
Packit Service |
21c75c |
import dnf.cli.commands.upgrade
|
|
Packit Service |
21c75c |
import dnf.pycomp
|
|
Packit Service |
21c75c |
import dnf.repo
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import tests.support
|
|
Packit Service |
21c75c |
from tests.support import mock
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class CommandsCliTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = []
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
super(CommandsCliTest, self).setUp()
|
|
Packit Service |
21c75c |
self.base.conf.persistdir = tempfile.mkdtemp()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_history_get_error_output_rollback_transactioncheckerror(self):
|
|
Packit Service |
21c75c |
"""Test get_error_output with the history rollback and a TransactionCheckError."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.history.HistoryCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_configure(cmd, ['rollback', '1'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
lines = cmd.get_error_output(dnf.exceptions.TransactionCheckError())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
lines,
|
|
Packit Service |
21c75c |
('Cannot rollback transaction 1, doing so would result in an '
|
|
Packit Service |
21c75c |
'inconsistent package database.',))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_history_get_error_output_undo_transactioncheckerror(self):
|
|
Packit Service |
21c75c |
"""Test get_error_output with the history undo and a TransactionCheckError."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.history.HistoryCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_configure(cmd, ['undo', '1'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
lines = cmd.get_error_output(dnf.exceptions.TransactionCheckError())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
lines,
|
|
Packit Service |
21c75c |
('Cannot undo transaction 1, doing so would result in an '
|
|
Packit Service |
21c75c |
'inconsistent package database.',))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_history_convert_tids(self):
|
|
Packit Service |
21c75c |
"""Test history _convert_tids()."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.history.HistoryCommand(self.cli)
|
|
Packit Service |
21c75c |
cmd.cli.base.output = mock.MagicMock()
|
|
Packit Service |
21c75c |
cmd.cli.base.output.history.last().tid = 123
|
|
Packit Service |
21c75c |
cmd.cli.base.output.history.search = mock.MagicMock(return_value=[99])
|
|
Packit Service |
21c75c |
tests.support.command_configure(cmd, ['list', '1..5', 'last', 'last-10', 'kernel'])
|
|
Packit Service |
21c75c |
self.assertEqual(cmd._args2transaction_ids(), ([123, 113, 99, 5, 4, 3, 2, 1], {(1, 5)}))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class CommandTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_canonical(self):
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.upgrade.UpgradeCommand(self.base.mock_cli())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
try:
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['cracker', 'filling'])
|
|
Packit Service |
21c75c |
except dnf.exceptions.Error as e:
|
|
Packit Service |
21c75c |
if e.value != 'No packages marked for upgrade.':
|
|
Packit Service |
21c75c |
raise
|
|
Packit Service |
21c75c |
self.assertEqual(cmd._basecmd, 'upgrade')
|
|
Packit Service |
21c75c |
self.assertEqual(cmd.opts.pkg_specs, ['cracker', 'filling'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class InstallCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.install.InstallCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(InstallCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self._cmd = dnf.cli.commands.install.InstallCommand(self.cli)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_configure(self):
|
|
Packit Service |
21c75c |
tests.support.command_configure(self._cmd, ['pkg'])
|
|
Packit Service |
21c75c |
self.assertFalse(self.cli.demands.allow_erasing)
|
|
Packit Service |
21c75c |
self.assertTrue(self.cli.demands.sack_activation)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands.install._',
|
|
Packit Service |
21c75c |
dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_group_notfound(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if the group cannot be found."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, self._cmd, ['@non-existent'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(stdout.getvalue(), "Module or Group 'non-existent' is not available.\n")
|
|
Packit Service |
21c75c |
self.assertResult(self._cmd.cli.base,
|
|
Packit Service |
21c75c |
self._cmd.cli.base.sack.query().installed())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run_package(self):
|
|
Packit Service |
21c75c |
"""Test whether a package is installed."""
|
|
Packit Service |
21c75c |
tests.support.command_run(self._cmd, ['lotus'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed(),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('lotus.x86_64').get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands.install._',
|
|
Packit Service |
21c75c |
dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_package_notfound(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if the package cannot be found."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, self._cmd, ['non-existent', 'lotus'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(stdout.getvalue(),
|
|
Packit Service |
21c75c |
'No match for argument: non-existent\n')
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed(),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('lotus.x86_64').get_best_query(self.base.sack))
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class ReinstallCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.ReinstallCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(ReinstallCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self._cmd = dnf.cli.commands.reinstall.ReinstallCommand(self.cli)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run(self):
|
|
Packit Service |
21c75c |
"""Test whether the package is installed."""
|
|
Packit Service |
21c75c |
tests.support.command_run(self._cmd, ['pepper'])
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='pepper'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('pepper.x86_64').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
.available()))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands.reinstall._',
|
|
Packit Service |
21c75c |
dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_notinstalled(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if the package is not installed."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error, tests.support.command_run, self._cmd, ['lotus'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(stdout.getvalue(), 'Package lotus available, but not installed.\n'
|
|
Packit Service |
21c75c |
'No match for argument: lotus\n')
|
|
Packit Service |
21c75c |
self.assertResult(self._cmd.cli.base,
|
|
Packit Service |
21c75c |
self._cmd.cli.base.sack.query().installed())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands.reinstall._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_notavailable(self):
|
|
Packit Service |
21c75c |
""" Test whether it fails if the package is not available. """
|
|
Packit Service |
21c75c |
holes_query = dnf.subject.Subject('hole').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in holes_query.installed():
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = "unknown"
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error, tests.support.command_run, self._cmd, ['hole'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
'Installed package hole-1-1.x86_64 (from unknown) not available.\n')
|
|
Packit Service |
21c75c |
self.assertResult(self.base, self.base.sack.query().installed())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsCommandTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = []
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(RepoPkgsCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self.cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_configure_badargs(self):
|
|
Packit Service |
21c75c |
"""Test whether the command fail in case of wrong args."""
|
|
Packit Service |
21c75c |
with self.assertRaises(SystemExit) as exit, \
|
|
Packit Service |
21c75c |
tests.support.patch_std_streams() as (stdout, stderr), \
|
|
Packit Service |
21c75c |
mock.patch('logging.Logger.critical'):
|
|
Packit Service |
21c75c |
tests.support.command_configure(self.cmd, [])
|
|
Packit Service |
21c75c |
self.assertEqual(exit.exception.code, 2)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsCheckUpdateSubCommandTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.CheckUpdateSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'updates', 'third_party']
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.term._real_term_width', return_value=80)
|
|
Packit Service |
21c75c |
def test(self, _real_term_width):
|
|
Packit Service |
21c75c |
""" Test whether only upgrades in the repository are listed. """
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed().filter(name='tour'):
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = "updates"
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['updates', 'check-update'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
u'\n'
|
|
Packit Service |
21c75c |
u'hole.x86_64 2-1'
|
|
Packit Service |
21c75c |
u' updates \n'
|
|
Packit Service |
21c75c |
u'pepper.x86_64 20-1'
|
|
Packit Service |
21c75c |
u' updates \n'
|
|
Packit Service |
21c75c |
u'Obsoleting Packages\n'
|
|
Packit Service |
21c75c |
u'hole.i686 2-1'
|
|
Packit Service |
21c75c |
u' updates \n'
|
|
Packit Service |
21c75c |
u' tour.noarch 5-0'
|
|
Packit Service |
21c75c |
u' @updates\n'
|
|
Packit Service |
21c75c |
u'hole.x86_64 2-1'
|
|
Packit Service |
21c75c |
u' updates \n'
|
|
Packit Service |
21c75c |
u' tour.noarch 5-0'
|
|
Packit Service |
21c75c |
u' @updates\n')
|
|
Packit Service |
21c75c |
self.assertEqual(self.cli.demands.success_exit_status, 100)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_not_found(self):
|
|
Packit Service |
21c75c |
"""Test whether exit code differs if updates are not found."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'check-update'])
|
|
Packit Service |
21c75c |
# self.assertNotEqual(self.cli.demands.success_exit_status, 100)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsInfoSubCommandTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.InfoSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
AVAILABLE_TITLE = u'Available Packages\n'
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
HOLE_I686_INFO = (u'Name : hole\n'
|
|
Packit Service |
21c75c |
u'Version : 2\n'
|
|
Packit Service |
21c75c |
u'Release : 1\n'
|
|
Packit Service |
21c75c |
u'Architecture : i686\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : updates\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n'
|
|
Packit Service |
21c75c |
u'\n')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
HOLE_X86_64_INFO = (u'Name : hole\n'
|
|
Packit Service |
21c75c |
u'Version : 2\n'
|
|
Packit Service |
21c75c |
u'Release : 1\n'
|
|
Packit Service |
21c75c |
u'Architecture : x86_64\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : updates\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n\n')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
INSTALLED_TITLE = u'Installed Packages\n'
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
PEPPER_SYSTEM_INFO = (u'Name : pepper\n'
|
|
Packit Service |
21c75c |
u'Version : 20\n'
|
|
Packit Service |
21c75c |
u'Release : 0\n'
|
|
Packit Service |
21c75c |
u'Architecture : x86_64\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : @System\n'
|
|
Packit Service |
21c75c |
u'From repo : main\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n\n')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
PEPPER_UPDATES_INFO = (u'Name : pepper\n'
|
|
Packit Service |
21c75c |
u'Version : 20\n'
|
|
Packit Service |
21c75c |
u'Release : 1\n'
|
|
Packit Service |
21c75c |
u'Architecture : x86_64\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : updates\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n\n')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'updates', 'third_party']
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(RepoPkgsInfoSubCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self.base.conf.recent = 7
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_all(self):
|
|
Packit Service |
21c75c |
"""Test whether only packages related to the repository are listed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed().filter(name='pepper'):
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = "main"
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'info', 'all', '*p*'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
''.join((
|
|
Packit Service |
21c75c |
self.INSTALLED_TITLE,
|
|
Packit Service |
21c75c |
self.PEPPER_SYSTEM_INFO,
|
|
Packit Service |
21c75c |
self.AVAILABLE_TITLE,
|
|
Packit Service |
21c75c |
u'Name : pepper\n'
|
|
Packit Service |
21c75c |
u'Version : 20\n'
|
|
Packit Service |
21c75c |
u'Release : 0\n'
|
|
Packit Service |
21c75c |
u'Architecture : src\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : main\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n'
|
|
Packit Service |
21c75c |
u'\n',
|
|
Packit Service |
21c75c |
u'Name : trampoline\n'
|
|
Packit Service |
21c75c |
u'Version : 2.1\n'
|
|
Packit Service |
21c75c |
u'Release : 1\n'
|
|
Packit Service |
21c75c |
u'Architecture : noarch\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : main\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n'
|
|
Packit Service |
21c75c |
u'\n')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_available(self):
|
|
Packit Service |
21c75c |
"""Test whether only packages in the repository are listed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['updates', 'info', 'available'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
''.join((
|
|
Packit Service |
21c75c |
self.AVAILABLE_TITLE,
|
|
Packit Service |
21c75c |
self.HOLE_I686_INFO,
|
|
Packit Service |
21c75c |
self.HOLE_X86_64_INFO,
|
|
Packit Service |
21c75c |
self.PEPPER_UPDATES_INFO)))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_extras(self):
|
|
Packit Service |
21c75c |
"""Test whether only extras installed from the repository are listed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed().filter(name='test'):
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = "main"
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'info', 'extras'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
u'Extra Packages\n'
|
|
Packit Service |
21c75c |
u'Name : test\n'
|
|
Packit Service |
21c75c |
u'Version : 1\n'
|
|
Packit Service |
21c75c |
u'Release : 0\n'
|
|
Packit Service |
21c75c |
u'Architecture : noarch\n'
|
|
Packit Service |
21c75c |
u'Size : 0.0 \n'
|
|
Packit Service |
21c75c |
u'Source : None\n'
|
|
Packit Service |
21c75c |
u'Repository : @System\n'
|
|
Packit Service |
21c75c |
u'From repo : main\n'
|
|
Packit Service |
21c75c |
u'Summary : \n'
|
|
Packit Service |
21c75c |
u'License : \n'
|
|
Packit Service |
21c75c |
u'Description : \n\n')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_installed(self):
|
|
Packit Service |
21c75c |
"""Test whether only packages installed from the repository are listed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed().filter(name='pepper'):
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = "main"
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'info', 'installed'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_obsoletes(self):
|
|
Packit Service |
21c75c |
"""Test whether only obsoletes in the repository are listed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['updates', 'info', 'obsoletes'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(
|
|
Packit Service |
21c75c |
stdout.getvalue(),
|
|
Packit Service |
21c75c |
''.join((
|
|
Packit Service |
21c75c |
u'Obsoleting Packages\n',
|
|
Packit Service |
21c75c |
self.HOLE_I686_INFO,
|
|
Packit Service |
21c75c |
self.HOLE_X86_64_INFO)))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_info_upgrades(self):
|
|
Packit Service |
21c75c |
"""Test whether only upgrades in the repository are listed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.patch_std_streams() as (stdout, _):
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['updates', 'info', 'upgrades'])
|
|
Packit Service |
21c75c |
self.assertEqual(stdout.getvalue(), ''.join((
|
|
Packit Service |
21c75c |
u'Available Upgrades\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsInstallSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.InstallSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['main', 'third_party']
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all(self):
|
|
Packit Service |
21c75c |
"""Test whether all packages from the repository are installed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['third_party', 'install'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
q = self.base.sack.query()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
q.installed(),
|
|
Packit Service |
21c75c |
q.available().filter(reponame='third_party', arch='x86_64', name__neq='hole'))
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsMoveToSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.MoveToSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ['distro', 'main']
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all(self):
|
|
Packit Service |
21c75c |
"""Test whether only packages in the repository are installed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['distro', 'move-to'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='tour'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('tour-5-0').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
.available()))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsReinstallOldSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.ReinstallOldSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all(self):
|
|
Packit Service |
21c75c |
"""Test whether all packages from the repository are reinstalled."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'main' if pkg.name != 'pepper' else 'non-main'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'reinstall-old'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='librita'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('librita.i686').get_best_query(self.base.sack).installed(),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('librita').get_best_query(self.base.sack).available())
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsReinstallSubCommandTest(tests.support.DnfBaseTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.ReinstallSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(RepoPkgsReinstallSubCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.mock = mock.Mock()
|
|
Packit Service |
21c75c |
old_run_patcher = mock.patch(
|
|
Packit Service |
21c75c |
'dnf.cli.commands.RepoPkgsCommand.ReinstallOldSubCommand.run_on_repo',
|
|
Packit Service |
21c75c |
self.mock.reinstall_old_run)
|
|
Packit Service |
21c75c |
move_run_patcher = mock.patch(
|
|
Packit Service |
21c75c |
'dnf.cli.commands.RepoPkgsCommand.MoveToSubCommand.run_on_repo',
|
|
Packit Service |
21c75c |
self.mock.move_to_run)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
old_run_patcher.start()
|
|
Packit Service |
21c75c |
self.addCleanup(old_run_patcher.stop)
|
|
Packit Service |
21c75c |
move_run_patcher.start()
|
|
Packit Service |
21c75c |
self.addCleanup(move_run_patcher.stop)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_fails(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if everything fails."""
|
|
Packit Service |
21c75c |
self.mock.reinstall_old_run.side_effect = dnf.exceptions.Error('test')
|
|
Packit Service |
21c75c |
self.mock.move_to_run.side_effect = dnf.exceptions.Error('test')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
self.assertRaises(
|
|
Packit Service |
21c75c |
dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run,
|
|
Packit Service |
21c75c |
cmd,
|
|
Packit Service |
21c75c |
['main', 'reinstall']
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(self.mock.mock_calls,
|
|
Packit Service |
21c75c |
[mock.call.reinstall_old_run(),
|
|
Packit Service |
21c75c |
mock.call.move_to_run()])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_moveto(self):
|
|
Packit Service |
21c75c |
"""Test whether reinstall-old is called first and move-to next."""
|
|
Packit Service |
21c75c |
self.mock.reinstall_old_run.side_effect = dnf.exceptions.Error('test')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'reinstall'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(self.mock.mock_calls,
|
|
Packit Service |
21c75c |
[mock.call.reinstall_old_run(),
|
|
Packit Service |
21c75c |
mock.call.move_to_run()])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_reinstallold(self):
|
|
Packit Service |
21c75c |
"""Test whether only reinstall-old is called."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'reinstall'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(self.mock.mock_calls,
|
|
Packit Service |
21c75c |
[mock.call.reinstall_old_run()])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsRemoveOrDistroSyncSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``RemoveOrDistroSyncSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["distro"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run_on_repo_spec_sync(self):
|
|
Packit Service |
21c75c |
"""Test running with a package which can be synchronized."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'non-distro' if pkg.name == 'pepper' else 'distro'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['non-distro', 'remove-or-distro-sync', 'pepper'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='pepper'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('pepper').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
.available()))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run_on_repo_spec_remove(self):
|
|
Packit Service |
21c75c |
"""Test running with a package which must be removed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'non-distro' if pkg.name == 'hole' else 'distro'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['non-distro', 'remove-or-distro-sync', 'hole'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(
|
|
Packit Service |
21c75c |
self.base,
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='hole'))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run_on_repo_all(self):
|
|
Packit Service |
21c75c |
"""Test running without a package specification."""
|
|
Packit Service |
21c75c |
nondist = {'pepper', 'hole'}
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'non-distro' if pkg.name in nondist else 'distro'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['non-distro', 'remove-or-distro-sync'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='pepper')
|
|
Packit Service |
21c75c |
.filter(name__neq='hole'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('pepper').get_best_query(self.base.sack)
|
|
Packit Service |
21c75c |
.available()))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_on_repo_spec_notinstalled(self):
|
|
Packit Service |
21c75c |
"""Test running with a package which is not installed."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, cmd,
|
|
Packit Service |
21c75c |
['non-distro', 'remove-or-distro-sync', 'not-installed'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertIn('No match for argument: not-installed\n', stdout.getvalue(),
|
|
Packit Service |
21c75c |
'mismatch not logged')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands._', dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_run_on_repo_all_notinstalled(self):
|
|
Packit Service |
21c75c |
"""Test running with a repository from which nothing is installed."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, cmd,
|
|
Packit Service |
21c75c |
['non-distro', 'remove-or-distro-sync'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertIn('No package installed from the repository.\n',
|
|
Packit Service |
21c75c |
stdout.getvalue(), 'mismatch not logged')
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsRemoveOrReinstallSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.RemoveOrReinstallSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["distro"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
"""Prepare the test fixture."""
|
|
Packit Service |
21c75c |
super(RepoPkgsRemoveOrReinstallSubCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self.cli = self.base.mock_cli()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_not_installed(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if no package is installed from the repository."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, cmd,
|
|
Packit Service |
21c75c |
['non-distro', 'remove-or-distro-sync'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, self.base.sack.query().installed())
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_reinstall(self):
|
|
Packit Service |
21c75c |
"""Test whether all packages from the repository are reinstalled."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'distro' if pkg.name != 'tour' else 'non-distro'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='tour'),
|
|
Packit Service |
21c75c |
dnf.subject.Subject('tour').get_best_query(self.base.sack).available())
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all_remove(self):
|
|
Packit Service |
21c75c |
"""Test whether all packages from the repository are removed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(
|
|
Packit Service |
21c75c |
self.base,
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='hole'))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsRemoveSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.RemoveSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["main"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all(self):
|
|
Packit Service |
21c75c |
"""Test whether only packages from the repository are removed."""
|
|
Packit Service |
21c75c |
tsis = []
|
|
Packit Service |
21c75c |
for pkg in self.base.sack.query().installed():
|
|
Packit Service |
21c75c |
reponame = 'main' if pkg.name == 'pepper' else 'non-main'
|
|
Packit Service |
21c75c |
pkg._force_swdb_repoid = reponame
|
|
Packit Service |
21c75c |
self.history.rpm.add_install(pkg)
|
|
Packit Service |
21c75c |
# tsi = dnf.transaction.TransactionItem(
|
|
Packit Service |
21c75c |
# dnf.transaction.INSTALL,
|
|
Packit Service |
21c75c |
# installed=pkg,
|
|
Packit Service |
21c75c |
# reason=libdnf.transaction.TransactionItemReason_USER
|
|
Packit Service |
21c75c |
# )
|
|
Packit Service |
21c75c |
# tsis.append(tsi)
|
|
Packit Service |
21c75c |
self._swdb_commit(tsis)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['main', 'remove'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(
|
|
Packit Service |
21c75c |
self.base,
|
|
Packit Service |
21c75c |
self.base.sack.query().installed().filter(name__neq='pepper')
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class RepoPkgsUpgradeSubCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.RepoPkgsCommand.UpgradeSubCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["updates", "third_party"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_all(self):
|
|
Packit Service |
21c75c |
"""Test whether all packages from the repository are installed."""
|
|
Packit Service |
21c75c |
cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
|
|
Packit Service |
21c75c |
tests.support.command_run(cmd, ['third_party', 'upgrade'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
q = self.base.sack.query()
|
|
Packit Service |
21c75c |
self.assertResult(self.base, itertools.chain(
|
|
Packit Service |
21c75c |
q.installed().filter(name__neq='hole'),
|
|
Packit Service |
21c75c |
q.upgrades().filter(reponame='third_party', arch='x86_64'))
|
|
Packit Service |
21c75c |
)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class UpgradeCommandTest(tests.support.ResultTestCase):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""Tests of ``dnf.cli.commands.upgrade.UpgradeCommand`` class."""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
REPOS = ["updates"]
|
|
Packit Service |
21c75c |
BASE_CLI = True
|
|
Packit Service |
21c75c |
CLI = "mock"
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def setUp(self):
|
|
Packit Service |
21c75c |
super(UpgradeCommandTest, self).setUp()
|
|
Packit Service |
21c75c |
self.cmd = dnf.cli.commands.upgrade.UpgradeCommand(self.cli)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def test_run(self):
|
|
Packit Service |
21c75c |
"""Test whether a package is updated."""
|
|
Packit Service |
21c75c |
tests.support.command_run(self.cmd, ['pepper'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertResult(self.cmd.base, itertools.chain(
|
|
Packit Service |
21c75c |
self.cmd.base.sack.query().installed().filter(name__neq='pepper'),
|
|
Packit Service |
21c75c |
self.cmd.base.sack.query().upgrades().filter(name='pepper')))
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@mock.patch('dnf.cli.commands.upgrade._',
|
|
Packit Service |
21c75c |
dnf.pycomp.NullTranslations().ugettext)
|
|
Packit Service |
21c75c |
def test_updatePkgs_notfound(self):
|
|
Packit Service |
21c75c |
"""Test whether it fails if the package cannot be found."""
|
|
Packit Service |
21c75c |
stdout = dnf.pycomp.StringIO()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
with tests.support.wiretap_logs('dnf', logging.INFO, stdout):
|
|
Packit Service |
21c75c |
self.assertRaises(dnf.exceptions.Error,
|
|
Packit Service |
21c75c |
tests.support.command_run, self.cmd, ['non-existent'])
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
self.assertEqual(stdout.getvalue(),
|
|
Packit Service |
21c75c |
'No match for argument: non-existent\n')
|
|
Packit Service |
21c75c |
self.assertResult(self.cmd.base, self.cmd.base.sack.query().installed())
|