Пример #1
0
    def test_info_all(self):
        """Test whether only packages related to the repository are listed."""
        for pkg in self._cmd.base.sack.query().installed().filter(
                name='pepper'):
            self._cmd.base.yumdb.db[str(
                pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'main'

        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('main', ['all', '*p*'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO,
                 self.AVAILABLE_TITLE, u'Name        : pepper\n'
                 u'Arch        : src\n'
                 u'Epoch       : 0\n'
                 u'Version     : 20\n'
                 u'Release     : 0\n'
                 u'Size        : 0.0  \n'
                 u'Repo        : main\n'
                 u'Summary     : \n'
                 u'License     : \n'
                 u'Description : \n'
                 u'\n', u'Name        : trampoline\n'
                 u'Arch        : noarch\n'
                 u'Epoch       : 0\n'
                 u'Version     : 2.1\n'
                 u'Release     : 1\n'
                 u'Size        : 0.0  \n'
                 u'Repo        : main\n'
                 u'Summary     : \n'
                 u'License     : \n'
                 u'Description : \n'
                 u'\n')))
Пример #2
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)
Пример #3
0
    def test_reponame(self):
        """Test whether only packages from the repository are uninstalled."""
        pkg_subj = dnf.subject.Subject('librita.x86_64')
        for pkg in pkg_subj.get_best_query(self.base.sack).installed():
            self.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.base.yumdb.get_package(pkg).from_repo = 'main'

        self.base.remove('librita', 'main')
        self.assertResult(self.base, itertools.chain(
              self.base.sack.query().installed().filter(name__neq='librita'),
              dnf.subject.Subject('librita.i686').get_best_query(self.base.sack)
              .installed()))
Пример #4
0
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        for pkg in self.cmd.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            self.cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cmd.base.yumdb.get_package(pkg).from_repo = reponame

        self.cmd.run('main', [])

        self.assertResult(
            self.cmd.base,
            self.cmd.base.sack.query().installed().filter(name__neq='pepper'))
Пример #5
0
    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        for pkg in self._cmd.base.sack.query().installed().filter(name='pepper'):
            self._cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'main'

        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('main', ['installed'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
Пример #6
0
    def test_reinstall_old_reponame_installed(self):
        """Test whether it reinstalls packages only from the repository."""
        for pkg in self.sack.query().installed().filter(name='librita'):
            self.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.base.yumdb.get_package(pkg).from_repo = 'main'

        reinstalled_count = self.base.reinstall('librita', old_reponame='main')

        self.assertEqual(reinstalled_count, 1)
        self.assertResult(self.base, itertools.chain(
            self.sack.query().installed().filter(name__neq='librita'),
            dnf.subject.Subject('librita.i686').get_best_query(self.sack).installed(),
            dnf.subject.Subject('librita').get_best_query(self.sack).available()))
Пример #7
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'))
Пример #8
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'))
Пример #9
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'))
Пример #10
0
    def test_all_reinstall(self):
        """Test whether all packages from the repository are reinstalled."""
        for pkg in self.cmd.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'tour' else 'non-distro'
            self.cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self.cmd.base.yumdb.get_package(pkg).from_repo = reponame

        self.cmd.run('non-distro', [])

        self.assertResult(self.cmd.base, itertools.chain(
              self.cmd.base.sack.query().installed().filter(name__neq='tour'),
              dnf.subject.Subject('tour').get_best_query(self.cmd.base.sack)
              .available()))
Пример #11
0
    def test_run_on_repo_spec_sync(self):
        """Test running with a package which can be synchronized."""
        for pkg in self.cli.base.sack.query().installed():
            data = support.RPMDBAdditionalDataPackageStub()
            data.from_repo = 'non-distro' if pkg.name == 'pepper' 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', 'pepper'])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='pepper'),
            dnf.subject.Subject('pepper').get_best_query(self.cli.base.sack)
            .available()))
Пример #12
0
    def test_all(self):
        """Test whether all packages from the repository are reinstalled."""
        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.ReinstallOldSubCommand(self.cli)
        cmd.run_on_repo('main', [])

        self.assertResult(self.cli.base, itertools.chain(
              self.cli.base.sack.query().installed().filter(name__neq='librita'),
              dnf.subject.Subject('librita.i686').get_best_query(self.cli.base.sack)
              .installed(),
              dnf.subject.Subject('librita').get_best_query(self.cli.base.sack)
              .available()))
Пример #13
0
    def test_run_notavailable(self):
        """Test whether it fails if the package is not available."""
        base = self._cmd.cli.base
        holes_query = dnf.subject.Subject('hole').get_best_query(base.sack)
        for pkg in holes_query.installed():
            self._cmd.base.yumdb.db[str(pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'unknown'
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, self._cmd.run, ['hole'])

        self.assertEqual(
            stdout.getvalue(),
            'Installed package hole-1-1.x86_64 (from unknown) not available.\n')
        self.assertResult(base, base.sack.query().installed())
Пример #14
0
    def test_run_on_repo_all(self):
        """Test running without a package specification."""
        nondist = {'pepper', 'hole'}
        for pkg in self.cli.base.sack.query().installed():
            data = support.RPMDBAdditionalDataPackageStub()
            data.from_repo = 'non-distro' if pkg.name in nondist else 'distro'
            self.cli.base.yumdb.db[str(pkg)] = data

        cmd = dnf.cli.commands.RepoPkgsCommand.RemoveOrDistroSyncSubCommand(
            self.cli)
        cmd.run_on_repo('non-distro', [])

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='pepper')
            .filter(name__neq='hole'),
            dnf.subject.Subject('pepper').get_best_query(self.cli.base.sack)
            .available()))
Пример #15
0
    def test_info_extras(self):
        """Test whether only extras installed from the repository are listed."""
        for pkg in self._cmd.base.sack.query().installed().filter(name='tour'):
            self._cmd.base.yumdb.db[str(
                pkg)] = support.RPMDBAdditionalDataPackageStub()
            self._cmd.base.yumdb.get_package(pkg).from_repo = 'unknown'

        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('unknown', ['extras'])

        self.assertEqual(
            stdout.getvalue(), u'Extra Packages\n'
            u'Name        : tour\n'
            u'Arch        : noarch\n'
            u'Epoch       : 0\n'
            u'Version     : 5\n'
            u'Release     : 0\n'
            u'Size        : 0.0  \n'
            u'Repo        : @System\n'
            u'From repo   : unknown\n'
            u'Summary     : \n'
            u'License     : \n'
            u'Description : \n\n')