def subtest_disable(self, label, fname):
        command_run(self.cmd, ['--set-disabled', label])

        with open(fname) as f:
            added = f.read()
        disabled = REPOCONTENT.replace("enabled=1", "enabled=0")
        self.assertMultiLineEqual(disabled, added)
示例#2
0
 def test_macro(self):
     with mock.patch('builddep.BuildDepCommand.base', MockBase()) as base:
         support.command_run(self.cmd,
                             ['--define', 'enable_optional_module 1', SPEC])
         self.assertEqual(
             set(base.marked),
             set(['emacs-extras', 'emacs-goodies >= 100', 'emacs-module']))
    def test_add_from_repofile(self):
        tempfile_kwargs = {'mode': 'w', 'suffix': '.repo', 'delete': False}
        if dnf.pycomp.PY3:
            tempfile_kwargs['encoding'] = 'utf8'

        repofile = tempfile.NamedTemporaryFile(**tempfile_kwargs)
        dnf.pycomp.write_to_file(repofile, REPOCONTENT)
        repofile.close()

        command_run(self.cmd, ['--add-repo', repofile.name])

        installed_repofile = os.path.join(self.cmd.base.conf.reposdir[0],
                                          os.path.basename(repofile.name))
        with open(installed_repofile) as f:
            added = f.read()

        self.assertMultiLineEqual(REPOCONTENT, added)

        def get_matching(x):
            repo = dnf.repo.Repo(x, '/tmp')
            repo.repofile = installed_repofile
            repo.cfg = iniparse.compat.RawConfigParser()
            repo.cfg.read(installed_repofile)
            return [repo]

        self.cmd.base.repos.get_matching = get_matching
        self.cmd.base.output = dnf.cli.output.Output(self.cmd.base,
                                                     self.cmd.base.conf)

        self.subtest_disable(REPOLABEL, installed_repofile)
        self.subtest_enable(REPOLABEL, installed_repofile)

        os.unlink(repofile.name)
    def test_add_from_repofile(self):
        tempfile_kwargs = {"mode": "w", "suffix": ".repo", "delete": False}
        if dnf.pycomp.PY3:
            tempfile_kwargs["encoding"] = "utf8"

        repofile = tempfile.NamedTemporaryFile(**tempfile_kwargs)
        dnf.pycomp.write_to_file(repofile, REPOCONTENT)
        repofile.close()

        command_run(self.cmd, ["--add-repo", repofile.name])

        installed_repofile = os.path.join(self.cmd.base.conf.reposdir[0], os.path.basename(repofile.name))
        with open(installed_repofile) as f:
            added = f.read()

        self.assertMultiLineEqual(REPOCONTENT, added)

        def get_matching(x):
            repo = dnf.repo.Repo(x, self.cmd.base.conf)
            repo.repofile = installed_repofile
            repo.cfg = iniparse.compat.RawConfigParser()
            repo.cfg.read(installed_repofile)
            return [repo]

        self.cmd.base.repos.get_matching = get_matching
        self.cmd.base.output = dnf.cli.output.Output(self.cmd.base, self.cmd.base.conf)

        self.subtest_disable(REPOLABEL, installed_repofile)
        self.subtest_enable(REPOLABEL, installed_repofile)

        os.unlink(repofile.name)
示例#5
0
    def test(self):
        """Test whether only upgrades in the repository are listed."""
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = 'updates'

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(),
            u'\n'
            u'hole.x86_64                              1-2'
            u'                            updates \n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
    def test_add_from_repofile(self):
        tempfile_kwargs = {'mode': 'w', 'suffix': '.repo', 'delete': False}
        if dnf.pycomp.PY3:
            tempfile_kwargs['encoding'] = 'utf8'

        repofile = tempfile.NamedTemporaryFile(**tempfile_kwargs)
        dnf.pycomp.write_to_file(repofile, REPOCONTENT)
        repofile.close()

        command_run(self.cmd, ['--add-repo', repofile.name])

        installed_repofile = os.path.join(self.cmd.base.conf.reposdir[0],
                                          os.path.basename(repofile.name))
        with open(installed_repofile) as f:
            added = f.read()

        self.assertMultiLineEqual(REPOCONTENT, added)

        def get_matching(x):
            repo = dnf.repo.Repo(x, self.cmd.base.conf)
            repo.repofile = installed_repofile
            return [repo]
        self.cmd.base.repos.get_matching = get_matching
        self.cmd.base.output = dnf.cli.output.Output(self.cmd.base, self.cmd.base.conf)

        self.subtest_disable(REPOLABEL, installed_repofile)
        self.subtest_enable(REPOLABEL, installed_repofile)

        os.unlink(repofile.name)
    def test_pkg_option(self):
        args = ["--pkg", "foo"]
        self.cmd.base.add_remote_rpms(
            [os.path.join(self.path, "noarch/foo-4-6.noarch.rpm")])
        with mock.patch("sys.stdout",
                        new_callable=dnf.pycomp.StringIO) as stdout:
            with self.assertRaises(dnf.exceptions.Error) as context:
                support.command_run(self.cmd, args)

            self.assertEqual(
                context.exception.value,
                "Repoclosure ended with unresolved dependencies (1) across 1 packages."
            )

            expected_out = [
                "package: foo-4-6.noarch from @commandline",
                "  unresolved deps (1):", "    bar = 4-6"
            ]
            self.assertEqual(stdout.getvalue()[:-1], "\n".join(expected_out))
        args = ["--pkg", "bar"]
        with mock.patch("sys.stdout",
                        new_callable=dnf.pycomp.StringIO) as stdout:
            with self.assertRaises(dnf.exceptions.Error) as context:
                support.command_run(self.cmd, args)
            self.assertEqual(context.exception.value,
                             "no package matched: bar")
示例#8
0
    def test(self):
        """ Test whether only upgrades in the repository are listed. """
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            mockSwdbPkg(history, pkg, repo='updates')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(),
            u'\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
示例#9
0
文件: test_group.py 项目: edynox/dnf
 def test_split_extcmds(self):
     cmd = group.GroupCommand(support.mock.MagicMock())
     cmd.base.conf = dnf.conf.Conf()
     support.command_run(cmd, ['install', 'crack'])
     cmd.base.env_group_install.assert_called_with(
         ['crack'], ('mandatory', 'default', 'conditional'),
         cmd.base.conf.strict)
示例#10
0
    def test_all_reinstallold(self):
        """Test whether only reinstall-old is called."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'reinstall'])

        self.assertEqual(self.mock.mock_calls,
                         [mock.call.reinstall_old_run()])
示例#11
0
    def test(self):
        """Test whether only upgrades in the repository are listed."""
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            self.cli.base._yumdb.db[str(
                pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = 'updates'

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(), u'\n'
            u'hole.x86_64                              1-2'
            u'                            updates \n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
示例#12
0
 def test_split_extcmds(self):
     cmd = group.GroupCommand(support.mock.MagicMock())
     cmd.base.conf = dnf.conf.Conf()
     support.command_run(cmd, ['install', 'crack'])
     cmd.base.env_group_install.assert_called_with(
         ['crack'], ('mandatory', 'default', 'conditional'),
         cmd.base.conf.strict)
示例#13
0
 def test_info_upgrades(self):
     """Test whether only upgrades in the repository are listed."""
     cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
     with support.patch_std_streams() as (stdout, _):
         support.command_run(cmd, ['updates', 'info', 'upgrades'])
     self.assertEqual(stdout.getvalue(), ''.join((
         u'Available Upgrades\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#14
0
    def test_all_reinstallold(self):
        """Test whether only reinstall-old is called."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'reinstall'])

        self.assertEqual(self.mock.mock_calls,
                         [mock.call.reinstall_old_run()])
示例#15
0
    def test_run(self):
        """Test whether a package is updated."""
        support.command_run(self.cmd, ['pepper'])

        self.assertResult(self.cmd.base, itertools.chain(
            self.cmd.base.sack.query().installed().filter(name__neq='pepper'),
            self.cmd.base.sack.query().upgrades().filter(name='pepper')))
示例#16
0
文件: test_commands.py 项目: jsgh/dnf
    def test(self, _real_term_width):
        """ Test whether only upgrades in the repository are listed. """
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(name='tour'):
            mockSwdbPkg(history, pkg, repo='updates')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'check-update'])

        self.assertEqual(
            stdout.getvalue(), u'\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'pepper.x86_64                            20-1'
            u'                           updates \n'
            u'Obsoleting Packages\n'
            u'hole.i686                                2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n'
            u'hole.x86_64                              2-1'
            u'                            updates \n'
            u'    tour.noarch                          5-0'
            u'                            @updates\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
    def subtest_disable(self, label, fname):
        command_run(self.cmd, ["--set-disabled", label])

        with open(fname) as f:
            added = f.read()
        disabled = REPOCONTENT.replace("enabled=1", "enabled=0")
        self.assertMultiLineEqual(disabled, added)
示例#18
0
文件: test_commands.py 项目: jsgh/dnf
    def test_info_all(self):
        """Test whether only packages related to the repository are listed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(
                name='pepper'):
            mockSwdbPkg(history, pkg, repo='main')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['main', 'info', 'all', '*p*'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO,
                 self.AVAILABLE_TITLE, u'Name         : pepper\n'
                 u'Version      : 20\n'
                 u'Release      : 0\n'
                 u'Arch         : src\n'
                 u'Size         : 0.0  \n'
                 u'Source       : None\n'
                 u'Repo         : main\n'
                 u'Summary      : \n'
                 u'License      : \n'
                 u'Description  : \n'
                 u'\n', u'Name         : trampoline\n'
                 u'Version      : 2.1\n'
                 u'Release      : 1\n'
                 u'Arch         : noarch\n'
                 u'Size         : 0.0  \n'
                 u'Source       : None\n'
                 u'Repo         : main\n'
                 u'Summary      : \n'
                 u'License      : \n'
                 u'Description  : \n'
                 u'\n')))
示例#19
0
    def test_run(self):
        """Test whether a package is updated."""
        support.command_run(self.cmd, ['pepper'])

        self.assertResult(self.cmd.base, itertools.chain(
            self.cmd.base.sack.query().installed().filter(name__neq='pepper'),
            self.cmd.base.sack.query().upgrades().filter(name='pepper')))
示例#20
0
 def test_info_upgrades(self):
     """Test whether only upgrades in the repository are listed."""
     cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
     with support.patch_std_streams() as (stdout, _):
         support.command_run(cmd, ['updates', 'info', 'upgrades'])
     self.assertEqual(stdout.getvalue(), ''.join((
         u'Available Upgrades\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#21
0
    def test_run_package(self):
        """Test whether a package is installed."""
        support.command_run(self._cmd, ['lotus'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('lotus.x86_64').get_best_query(base.sack)))
示例#22
0
    def test_run_group(self):
        """Test whether a group is installed."""
        support.command_run(self._cmd, ['@Solid Ground'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('trampoline').get_best_query(base.sack)))
示例#23
0
    def test_run_group(self):
        """Test whether a group is installed."""
        support.command_run(self._cmd, ['@Solid Ground'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('trampoline').get_best_query(base.sack)))
示例#24
0
    def test_run_package(self):
        """Test whether a package is installed."""
        support.command_run(self._cmd, ['lotus'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
              base.sack.query().installed(),
              dnf.subject.Subject('lotus.x86_64').get_best_query(base.sack)))
示例#25
0
 def test_space_option(self):
     args = ["--new", "--space", self.path]
     with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_list = ["foo-4-8.src.rpm",
                          "noarch/foo-4-8.noarch.rpm"]
         self.assertEqual(stdout.getvalue()[:-1],
             " ".join(self._path_join_in_list(expected_list, self.path)))
示例#26
0
    def test_all(self):
        """Test whether the package from the repository is installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['updates', 'upgrade', 'hole-1-2'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='hole'),
            dnf.subject.Subject('hole-1-2.x86_64').get_best_query(self.cli.base.sack)
            .filter(reponame='updates')))
示例#27
0
    def test_all(self):
        """Test whether only packages in the repository are installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['distro', 'move-to'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='tour'),
            dnf.subject.Subject('tour-5-0').get_best_query(self.cli.base.sack)
            .available()))
示例#28
0
    def test_all(self):
        """Test whether all packages from the repository are installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['third_party', 'upgrade'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='hole'),
            self.cli.base.sack.query().upgrades().filter(reponame='third_party',
                                                         arch='x86_64')))
示例#29
0
    def test_run(self):
        """Test whether the package is installed."""
        support.command_run(self._cmd, ['pepper'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
            base.sack.query().installed().filter(name__neq='pepper'),
            dnf.subject.Subject('pepper.x86_64').get_best_query(base.sack)
            .available()))
示例#30
0
 def test_base(self):
     args = []
     self.cmd.base.add_remote_rpms([os.path.join(self.path, "noarch/foo-4-6.noarch.rpm")])
     with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_out = ["package: foo-4-6.noarch from @commandline",
                         "  unresolved deps:",
                         "    bar = 4-6"]
         self.assertEqual(stdout.getvalue()[:-1], "\n".join(expected_out))
示例#31
0
 def test_header(self):
     args = []
     with mock.patch("sys.stdout",
                     new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_graph = [
             "digraph packages {", repograph.DOT_HEADER, "}\n"
         ]
         self.assertEqual(stdout.getvalue(), "\n".join(expected_graph))
示例#32
0
    def test_run(self):
        """Test whether the package is installed."""
        support.command_run(self._cmd, ['pepper'])

        base = self._cmd.cli.base
        self.assertResult(base, itertools.chain(
            base.sack.query().installed().filter(name__neq='pepper'),
            dnf.subject.Subject('pepper.x86_64').get_best_query(base.sack)
            .available()))
示例#33
0
    def test_all(self):
        """Test whether all packages from the repository are installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['third_party', 'upgrade'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='hole'),
            self.cli.base.sack.query().upgrades().filter(reponame='third_party',
                                                         arch='x86_64')))
示例#34
0
    def test_all(self):
        """Test whether the package from the repository is installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['updates', 'upgrade', 'hole-1-2'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='hole'),
            dnf.subject.Subject('hole-1-2.x86_64').get_best_query(self.cli.base.sack)
            .filter(reponame='updates')))
示例#35
0
    def test_all(self):
        """Test whether only packages in the repository are installed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['distro', 'move-to'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='tour'),
            dnf.subject.Subject('tour-5-0').get_best_query(self.cli.base.sack)
            .available()))
示例#36
0
    def test_all_moveto(self):
        """Test whether reinstall-old is called first and move-to next."""
        self.mock.reinstall_old_run.side_effect = dnf.exceptions.Error('test')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'reinstall'])

        self.assertEqual(self.mock.mock_calls,
                         [mock.call.reinstall_old_run(),
                          mock.call.move_to_run()])
示例#37
0
 def test_canonical(self):
     cmd = dnf.cli.commands.upgrade.UpgradeCommand(
                             support.BaseCliStub('main').mock_cli())
     try:
         support.command_run(cmd, ['cracker', 'filling'])
     except dnf.exceptions.Error as e:
         if e.value != 'No packages marked for upgrade.':
             raise
     self.assertEqual(cmd.basecmd, 'upgrade')
     self.assertEqual(cmd.opts.pkg_specs, ['cracker', 'filling'])
示例#38
0
    def test_all_moveto(self):
        """Test whether reinstall-old is called first and move-to next."""
        self.mock.reinstall_old_run.side_effect = dnf.exceptions.Error('test')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'reinstall'])

        self.assertEqual(self.mock.mock_calls,
                         [mock.call.reinstall_old_run(),
                          mock.call.move_to_run()])
示例#39
0
 def test_canonical(self):
     cmd = dnf.cli.commands.upgrade.UpgradeCommand(
         support.BaseCliStub('main').mock_cli())
     try:
         support.command_run(cmd, ['cracker', 'filling'])
     except dnf.exceptions.Error as e:
         if e.value != 'No packages marked for upgrade.':
             raise
     self.assertEqual(cmd._basecmd, 'upgrade')
     self.assertEqual(cmd.opts.pkg_specs, ['cracker', 'filling'])
示例#40
0
    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'info', 'obsoletes'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (u'Obsoleting Packages\n', self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO)))
示例#41
0
    def test_info_available(self):
        """Test whether only packages in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'info', 'available'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.AVAILABLE_TITLE, self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#42
0
 def test_old_option(self):
     args = ["--old", self.path]
     with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
         support.command_run(self.cmd, args)
         expected_list = ["foo-4-6.src.rpm",
                          "foo-4-7.src.rpm",
                          "noarch/foo-4-6.noarch.rpm",
                          "noarch/foo-4-7.noarch.rpm"]
         self.assertEqual(stdout.getvalue().split(),
             self._path_join_in_list(expected_list, self.path))
示例#43
0
    def test_info_recent(self):
        """Test whether only packages in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with mock.patch('time.time', return_value=0), \
                support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'info', 'recent'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (u'Recently Added Packages\n', self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#44
0
    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'info', 'obsoletes'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Obsoleting Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO)))
示例#45
0
    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed().filter(name='pepper'):
            mockSwdbPkg(history, pkg, repo='main')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['main', 'info', 'installed'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
示例#46
0
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = reponame

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'remove'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='pepper'))
示例#47
0
文件: test_commands.py 项目: jsgh/dnf
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'remove'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='pepper'))
示例#48
0
    def test_run_on_repo_spec_remove(self):
        """Test running with a package which must be removed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name == 'hole' else 'distro'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-distro-sync', 'hole'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))
示例#49
0
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = reponame

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'remove'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='pepper'))
示例#50
0
    def test_all_remove(self):
        """Test whether all packages from the repository are removed."""
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = reponame

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))
示例#51
0
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['main', 'remove'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='pepper'))
示例#52
0
    def test_all_remove(self):
        """Test whether all packages from the repository are removed."""
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = reponame

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))
示例#53
0
    def test_run_on_repo_spec_remove(self):
        """Test running with a package which must be removed."""
        for pkg in self.cli.base.sack.query().installed():
            data = support.RPMDBAdditionalDataPackageStub()
            data.from_repo = 'non-distro' if pkg.name == 'hole' else 'distro'
            self.cli.base._yumdb.db[str(pkg)] = data

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-distro-sync', 'hole'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))
示例#54
0
    def test_all_remove(self):
        """Test whether all packages from the repository are removed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))
示例#55
0
    def test_info_available(self):
        """Test whether only packages in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['updates', 'info', 'available'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                self.AVAILABLE_TITLE,
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
示例#56
0
    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        for pkg in self.cli.base.sack.query().installed().filter(name='pepper'):
            self.cli.base._yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cli.base._yumdb.get_package(pkg).from_repo = 'main'

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            support.command_run(cmd, ['main', 'info', 'installed'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
示例#57
0
文件: test_commands.py 项目: jsgh/dnf
    def test_all_remove(self):
        """Test whether all packages from the repository are removed."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        support.command_run(cmd, ['non-distro', 'remove-or-reinstall'])

        self.assertResult(
            self.cli.base,
            self.cli.base.sack.query().installed().filter(name__neq='hole'))