Example #1
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)
Example #2
0
    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)
Example #3
0
    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')))
Example #4
0
    def test_list_installed_reponame(self):
        """Test whether only packages installed from the repository are listed."""
        base = support.MockBase()
        expected = base.sack.query().installed().filter(name={'pepper',
                                                              'librita'})
        history = base.history
        for pkg in expected:
            support.mockSwdbPkg(history, pkg, repo='main')

        lists = base._do_package_lists('installed', reponame='main')

        self.assertCountEqual(lists.installed, expected)
Example #5
0
    def test_all(self):
        """Test whether only packages from the repository are removed."""
        for pkg in self.base.sack.query().installed():
            reponame = 'main' if pkg.name == 'pepper' else 'non-main'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

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

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

        self.assertResult(
            self.base,
            self.base.sack.query().installed().filter(name__neq='hole'))
Example #7
0
    def test_list_installed_reponame(self):
        """Test whether only packages installed from the repository are listed."""
        base = support.MockBase()
        expected = base.sack.query().installed().filter(
            name={'pepper', 'librita'})
        history = base.history
        for pkg in expected:
            support.mockSwdbPkg(history, pkg, repo='main')

        lists = base._do_package_lists('installed', reponame='main')

        self.assertCountEqual(lists.installed, expected)
Example #8
0
    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        for pkg in self.base.sack.query().installed().filter(name='pepper'):
            mockSwdbPkg(self.history, pkg, repo='main')

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

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
Example #9
0
    def test_all_remove(self):
        """Test whether all packages from the repository are removed."""
        for pkg in self.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'hole' else 'non-distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        self.assertResult(
            self.base,
            self.base.sack.query().installed().filter(name__neq='hole'))
Example #10
0
    def test_reponame(self):
        """Test whether only packages from the repository are uninstalled."""
        pkg_subj = dnf.subject.Subject('librita.x86_64')
        history = self.base.history
        for pkg in pkg_subj.get_best_query(self.base.sack).installed():
            support.mockSwdbPkg(history, pkg, 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()))
Example #11
0
    def test_run_on_repo_spec_remove(self):
        """Test running with a package which must be removed."""
        for pkg in self.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name == 'hole' else 'distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        self.assertResult(
            self.base,
            self.base.sack.query().installed().filter(name__neq='hole'))
Example #12
0
    def test_info_installed(self):
        """Test whether only packages installed from the repository are listed."""
        for pkg in self.base.sack.query().installed().filter(name='pepper'):
            mockSwdbPkg(self.history, pkg, repo='main')

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

        self.assertEqual(
            stdout.getvalue(),
            ''.join((self.INSTALLED_TITLE, self.PEPPER_SYSTEM_INFO)))
Example #13
0
    def test_reinstall_old_reponame_installed(self):
        """Test whether it reinstalls packages only from the repository."""
        history = self.base.history
        for pkg in self.sack.query().installed().filter(name='librita'):
            support.mockSwdbPkg(history, pkg, 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()))
Example #14
0
    def test_all_reinstall(self):
        """Test whether all packages from the repository are reinstalled."""
        for pkg in self.base.sack.query().installed():
            reponame = 'distro' if pkg.name != 'tour' else 'non-distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        self.assertResult(self.base, itertools.chain(
            self.base.sack.query().installed().filter(name__neq='tour'),
            dnf.subject.Subject('tour').get_best_query(self.base.sack).available())
        )
Example #15
0
    def test_run_on_repo_spec_sync(self):
        """Test running with a package which can be synchronized."""
        for pkg in self.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name == 'pepper' else 'distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        self.assertResult(self.base, itertools.chain(
            self.base.sack.query().installed().filter(name__neq='pepper'),
            dnf.subject.Subject('pepper').get_best_query(self.base.sack)
            .available()))
Example #16
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'))
Example #17
0
    def test_run_on_repo_spec_remove(self):
        """Test running with a package which must be removed."""
        for pkg in self.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name == 'hole' else 'distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

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

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

        self.assertResult(self.cli.base, itertools.chain(
            self.cli.base.sack.query().installed().filter(name__neq='tour'),
            dnf.subject.Subject('tour').get_best_query(self.cli.base.sack).available())
        )
Example #19
0
    def test_run_on_repo_spec_sync(self):
        """Test running with a package which can be synchronized."""
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name == 'pepper' else 'distro'
            mockSwdbPkg(history, pkg, repo=reponame)

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        tests.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()))
Example #20
0
    def test_reponame(self):
        """Test whether only packages from the repository are uninstalled."""
        pkg_subj = dnf.subject.Subject('librita.x86_64')
        history = self.base.history
        for pkg in pkg_subj.get_best_query(self.base.sack).installed():
            support.mockSwdbPkg(history, pkg, 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()))
Example #21
0
    def test_all(self):
        """Test whether all packages from the repository are reinstalled."""
        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)
        tests.support.command_run(cmd, ['main', 'reinstall-old'])

        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())
        )
Example #22
0
    def test_run_on_repo_all(self):
        """Test running without a package specification."""
        nondist = {'pepper', 'hole'}
        for pkg in self.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name in nondist else 'distro'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        self.assertResult(self.base, itertools.chain(
            self.base.sack.query().installed().filter(name__neq='pepper')
            .filter(name__neq='hole'),
            dnf.subject.Subject('pepper').get_best_query(self.base.sack)
            .available()))
Example #23
0
    def test_run_notavailable(self):
        """ Test whether it fails if the package is not available. """
        holes_query = dnf.subject.Subject('hole').get_best_query(self.base.sack)
        for pkg in holes_query.installed():
            mockSwdbPkg(self.history, pkg)

        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(
            stdout.getvalue(),
            'Installed package hole-1-1.x86_64 (from unknown) not available.\n')
        self.assertResult(self.base, self.base.sack.query().installed())
Example #24
0
    def test_run_on_repo_all(self):
        """Test running without a package specification."""
        nondist = {'pepper', 'hole'}
        history = self.cli.base.history
        for pkg in self.cli.base.sack.query().installed():
            reponame = 'non-distro' if pkg.name in nondist else 'distro'
            mockSwdbPkg(history, pkg, repo=reponame)

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

        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()))
Example #25
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)
        history = self._cmd.base.history
        for pkg in holes_query.installed():
            mockSwdbPkg(history, pkg)

        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(
            stdout.getvalue(),
            'Installed package hole-1-1.x86_64 (from unknown) not available.\n')
        self.assertResult(base, base.sack.query().installed())
Example #26
0
    def test_reinstall_old_reponame_installed(self):
        """Test whether it reinstalls packages only from the repository."""
        history = self.base.history
        for pkg in self.sack.query().installed().filter(name='librita'):
            support.mockSwdbPkg(history, pkg, 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()))
Example #27
0
    def test_all(self):
        """Test whether all packages from the repository are reinstalled."""
        for pkg in self.base.sack.query().installed():
            reponame = 'main' if pkg.name != 'pepper' else 'non-main'
            mockSwdbPkg(self.history, pkg, repo=reponame)

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

        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(),
                dnf.subject.Subject('librita').get_best_query(
                    self.base.sack).available()))
Example #28
0
    def test_info_extras(self):
        """Test whether only extras installed from the repository are listed."""
        for pkg in self.base.sack.query().installed().filter(name='tour'):
            mockSwdbPkg(self.history, pkg, repo='main')

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

        self.assertEqual(
            stdout.getvalue(), u'Extra Packages\n'
            u'Name         : tour\n'
            u'Version      : 5\n'
            u'Release      : 0\n'
            u'Arch         : noarch\n'
            u'Size         : 0.0  \n'
            u'Source       : None\n'
            u'Repo         : @System\n'
            u'From repo    : main\n'
            u'Summary      : \n'
            u'License      : \n'
            u'Description  : \n\n')
Example #29
0
    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')))
Example #30
0
    def test_info_extras(self):
        """Test whether only extras installed from the repository are listed."""
        for pkg in self.base.sack.query().installed().filter(name='tour'):
            mockSwdbPkg(self.history, pkg, repo='main')

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

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