示例#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_setup(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging._setup(logging.INFO, logging.ERROR, self.logdir)
         self._bench(logger)
     self.assertEqual("i\n", stdout.getvalue())
     self.assertEqual("e\n", stderr.getvalue())
示例#3
0
 def test_setup_verbose(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging.setup(logging.DEBUG, logging.WARNING, self.logdir)
         self._bench(logger)
     self.assertEqual("d\ni\n", stdout.getvalue())
     self.assertEqual("w\ne\n", stderr.getvalue())
示例#4
0
 def test_setup_verbose(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging._setup(logging.DEBUG, logging.WARNING, self.logdir)
         self._bench(logger)
     self.assertEqual("d\ni\n", stdout.getvalue())
     self.assertEqual("w\ne\n", stderr.getvalue())
示例#5
0
 def test_setup(self):
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         self.logging.setup(logging.INFO, logging.ERROR, self.logdir)
         self._bench(logger)
     self.assertEqual("i\n", stdout.getvalue())
     self.assertEqual("e\n", stderr.getvalue())
示例#6
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)))
示例#7
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)))
示例#8
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)
示例#9
0
 def test_configure_badargs(self):
     """Test whether the command fail in case of wrong args."""
     with self.assertRaises(SystemExit) as exit, \
         support.patch_std_streams() as (stdout, stderr), \
         mock.patch('logging.Logger.critical') as clog:
         support.command_configure(self.cmd, [])
     self.assertEqual(exit.exception.code, 1)
示例#10
0
 def test_configure_badargs(self):
     """Test whether the command fail in case of wrong args."""
     with self.assertRaises(SystemExit) as exit, \
         support.patch_std_streams() as (stdout, stderr), \
         mock.patch('logging.Logger.critical') as clog:
         support.command_configure(self.cmd, [])
     self.assertEqual(exit.exception.code, 1)
示例#11
0
文件: test_commands.py 项目: Xake/dnf
    def test(self):
        """Test whether only upgrades in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand.CheckUpdateSubCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            cmd.run_on_repo('updates', [])

        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'                            @System\n'
            u'hole.x86_64                               2-1'
            u'                            updates\n'
            u'    tour.noarch                           5-0'
            u'                            @System\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
示例#12
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')))
示例#13
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)
示例#14
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)
示例#15
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)
示例#16
0
    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['obsoletes'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (u'Obsoleting Packages\n', self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO)))
示例#17
0
    def test_info_available(self):
        """Test whether only packages in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['available'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.AVAILABLE_TITLE, self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#18
0
 def test_obsoleted(self):
     self.cmd = dnf.cli.commands.check.CheckCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['--obsoleted'])
     with support.patch_std_streams() as (stdout, _):
         with self.assertRaises(dnf.exceptions.Error) as ctx:
             self.cmd.run()
         self.assertEqual(str(ctx.exception),
                          'Check discovered 1 problem(s)')
     self.assertEqual(stdout.getvalue(), EXPECTED_OBSOLETED_FORMAT)
示例#19
0
    def test_info_recent(self):
        """Test whether only packages in the repository are listed."""
        with mock.patch('time.time', return_value=0), \
                support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['recent'])

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

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (self.AVAILABLE_TITLE, self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#21
0
文件: test_check.py 项目: yurchor/dnf
 def test_obsoleted(self):
     self.cmd = dnf.cli.commands.check.CheckCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['--obsoleted'])
     with support.patch_std_streams() as (stdout, _):
         with self.assertRaises(dnf.exceptions.Error) as ctx:
             self.cmd.run()
         self.assertEqual(str(ctx.exception),
                          'Check discovered 1 problem(s)')
     self.assertEqual(stdout.getvalue(), EXPECTED_OBSOLETED_FORMAT)
示例#22
0
    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        cmd = dnf.cli.commands.RepoPkgsCommand.InfoSubCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            cmd.run_on_repo('updates', ['obsoletes'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (u'Obsoleting Packages\n', self.HOLE_I686_INFO,
                 self.HOLE_X86_64_INFO)))
示例#23
0
    def test_info_obsoletes(self):
        """Test whether only obsoletes in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['obsoletes'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Obsoleting Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO)))
示例#24
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)))
示例#25
0
    def test_info_available(self):
        """Test whether only packages in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['available'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                self.AVAILABLE_TITLE,
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
示例#26
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)))
示例#27
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)))
示例#28
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)))
示例#29
0
    def test_info_recent(self):
        """Test whether only packages in the repository are listed."""
        with mock.patch('time.time', return_value=0), \
                support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['recent'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Recently Added Packages\n',
                self.HOLE_I686_INFO,
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
示例#30
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)))
示例#31
0
文件: test_commands.py 项目: jsgh/dnf
    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)))
示例#32
0
 def test_rpm_logging(self):
     # log everything to the console:
     self.logging.setup(dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG,
                       self.logdir)
     logger = logging.getLogger("dnf.rpm")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info('rpm transaction happens.')
     # rpm logger never outputs to the console:
     self.assertEqual(stdout.getvalue(), "")
     self.assertEqual(stderr.getvalue(), "")
     logfile = os.path.join(self.logdir, "dnf.rpm.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs =  map(operator.attrgetter("message"),
                     map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(msgs, [dnf.const.LOG_MARKER,
                                     'rpm transaction happens.'])
示例#33
0
 def test_file_logging(self):
     # log nothing to the console:
     self.logging._setup(dnf.logging.SUPERCRITICAL,
                         dnf.logging.SUPERCRITICAL, self.logdir)
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info("i")
         logger.critical("c")
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
     # yet the file should contain both the entries:
     logfile = os.path.join(self.logdir, "dnf.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs = map(operator.attrgetter("message"),
                    map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(list(msgs), [dnf.const.LOG_MARKER, 'i', 'c'])
示例#34
0
 def test_file_logging(self):
     # log nothing to the console:
     self.logging.setup(dnf.logging.SUPERCRITICAL, dnf.logging.SUPERCRITICAL,
                       self.logdir)
     logger = logging.getLogger("dnf")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info("i")
         logger.critical("c")
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
     # yet the file should contain both the entries:
     logfile = os.path.join(self.logdir, "dnf.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs =  map(operator.attrgetter("message"),
                     map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(msgs, [dnf.const.LOG_MARKER, 'i', 'c'])
示例#35
0
 def test_rpm_logging(self):
     # log everything to the console:
     self.logging._setup(dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG,
                         self.logdir)
     logger = logging.getLogger("dnf.rpm")
     with support.patch_std_streams() as (stdout, stderr):
         logger.info('rpm transaction happens.')
     # rpm logger never outputs to the console:
     self.assertEqual(stdout.getvalue(), "")
     self.assertEqual(stderr.getvalue(), "")
     logfile = os.path.join(self.logdir, "dnf.rpm.log")
     self.assertFile(logfile)
     with open(logfile) as f:
         msgs = map(operator.attrgetter("message"),
                    map(_split_logfile_entry, f.readlines()))
     self.assertSequenceEqual(
         list(msgs), [dnf.const.LOG_MARKER, 'rpm transaction happens.'])
示例#36
0
    def test_info_upgrades(self):
        """Test whether only upgrades in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['upgrades'])

        self.assertEqual(
            stdout.getvalue(), ''.join(
                (u'Upgraded Packages\n'
                 u'Name        : hole\n'
                 u'Arch        : x86_64\n'
                 u'Epoch       : 0\n'
                 u'Version     : 1\n'
                 u'Release     : 2\n'
                 u'Size        : 0.0  \n'
                 u'Repo        : updates\n'
                 u'Summary     : \n'
                 u'License     : \n'
                 u'Description : \n'
                 u'\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#37
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'Upgraded Packages\n'
                 u'Name         : hole\n'
                 u'Version      : 1\n'
                 u'Release      : 2\n'
                 u'Arch         : x86_64\n'
                 u'Size         : 0.0  \n'
                 u'Source       : None\n'
                 u'Repo         : updates\n'
                 u'Summary      : \n'
                 u'License      : \n'
                 u'Description  : \n'
                 u'\n', self.HOLE_X86_64_INFO, self.PEPPER_UPDATES_INFO)))
示例#38
0
    def test_info_upgrades(self):
        """Test whether only upgrades in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', ['upgrades'])

        self.assertEqual(
            stdout.getvalue(),
            ''.join((
                u'Upgraded Packages\n'
                u'Name        : hole\n'
                u'Arch        : x86_64\n'
                u'Epoch       : 0\n'
                u'Version     : 1\n'
                u'Release     : 2\n'
                u'Size        : 0.0  \n'
                u'Repo        : updates\n'
                u'Summary     : \n'
                u'License     : None\n'
                u'Description : \n'
                u'\n',
                self.HOLE_X86_64_INFO,
                self.PEPPER_UPDATES_INFO)))
示例#39
0
    def test_info_all(self):
        """Test whether only packages related to 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', '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')))
示例#40
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')
示例#41
0
文件: test_commands.py 项目: jsgh/dnf
    def test_info_extras(self):
        """Test whether only extras installed from 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='main')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            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')
示例#42
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     : None\n'
            u'Description : \n\n')
示例#43
0
    def test(self):
        """Test whether only upgrades in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', [])

        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'                            @System\n'
            u'hole.x86_64                               2-1'
            u'                            updates\n'
            u'    tour.noarch                           5-0'
            u'                            @System\n')
        self.assertEqual(self.cli.demands.success_exit_status, 100)
示例#44
0
    def test_info_extras(self):
        """Test whether only extras installed from 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='main')

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.patch_std_streams() as (stdout, _):
            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')
示例#45
0
    def test(self):
        """Test whether only upgrades in the repository are listed."""
        with support.patch_std_streams() as (stdout, _):
            self._cmd.run('updates', [])

        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'                            @System\n'
            u'hole.x86_64                               2-1'
            u'                            updates\n'
            u'    tour.noarch                           5-0'
            u'                            @System\n')
        self.assertEqual(self._cmd.success_retval, 100)
示例#46
0
 def test_conflict(self):
     with self.assertRaises(SystemExit) as sysexit, \
         support.patch_std_streams() as (stdout, stderr):
         support.command_configure(self.cmd,
                                   ['--conflicts', '%{name}', '--provides'])
     self.assertEqual(sysexit.exception.code, 1)
示例#47
0
 def test_group_verbose_info(self, _term_width):
     group = self.base.comps.group_by_pattern('Peppers')
     self.output.conf.verbose = True
     with support.patch_std_streams() as (stdout, stderr):
         self.output.displayPkgsInGroups(group)
     self.assertEqual(stdout.getvalue(), PKGS_IN_GROUPS_VERBOSE_OUTPUT)
示例#48
0
 def test_conflict(self):
     with self.assertRaises(SystemExit) as sysexit, \
         support.patch_std_streams() as (stdout, stderr):
         support.command_configure(self.cmd,
                                   ['--conflicts', '%{name}', '--provides'])
     self.assertEqual(sysexit.exception.code, 1)
示例#49
0
 def patched_search(self, *args):
     with support.patch_std_streams() as (stdout, _):
         support.command_run(self.cmd, *args)
         call_args = self.base.output.matchcallback.call_args_list
         pkgs = [c[0][0] for c in call_args]
         return (stdout.getvalue(), pkgs)
示例#50
0
 def test_group_verbose_info(self, _term_width):
     group = self.base.comps.group_by_pattern('Peppers')
     self.output.conf.verbose = True
     with support.patch_std_streams() as (stdout, stderr):
         self.output.display_pkgs_in_groups(group)
     self.assertEqual(stdout.getvalue(), PKGS_IN_GROUPS_VERBOSE_OUTPUT)
示例#51
0
文件: test_cli.py 项目: zde/dnf
 def patched_search(self, *args, **kwargs):
     with support.patch_std_streams() as (stdout, stderr):
         self.cli.search(*args, **kwargs)
         call_args = self.yumbase.output.matchcallback.call_args_list
         pkgs = [c[0][0] for c in call_args]
         return (stdout.getvalue(), pkgs)
示例#52
0
 def test_environment_info(self, _term_width):
     env = self.base.comps.environments[0]
     with support.patch_std_streams() as (stdout, stderr):
         self.output.display_groups_in_environment(env)
     self.assertEqual(stdout.getvalue(), GROUPS_IN_ENVIRONMENT_OUTPUT)
示例#53
0
 def test_group_info(self, _term_width):
     group = self.base.comps.group_by_pattern('Peppers')
     with support.patch_std_streams() as (stdout, stderr):
         self.output.displayPkgsInGroups(group)
     self.assertEqual(stdout.getvalue(), PKGS_IN_GROUPS_OUTPUT)
示例#54
0
 def test_group_info(self, _term_width):
     group = self.base.comps.group_by_pattern('Peppers')
     with support.patch_std_streams() as (stdout, stderr):
         self.output.display_pkgs_in_groups(group)
     self.assertEqual(stdout.getvalue(), PKGS_IN_GROUPS_OUTPUT)
示例#55
0
 def test_environment_info(self, _term_width):
     env = self.base.comps.environments[0]
     with support.patch_std_streams() as (stdout, stderr):
         self.output.display_groups_in_environment(env)
     self.assertEqual(stdout.getvalue(), GROUPS_IN_ENVIRONMENT_OUTPUT)
示例#56
0
 def test_group_verbose_info(self, _term_width):
     group = self.base.comps.group_by_pattern('Peppers')
     self.base.set_debuglevel(dnf.const.VERBOSE_LEVEL)
     with support.patch_std_streams() as (stdout, stderr):
         self.output.display_pkgs_in_groups(group)
     self.assertEqual(stdout.getvalue(), PKGS_IN_GROUPS_VERBOSE_OUTPUT)
示例#57
0
 def patched_search(self, *args, **kwargs):
     with support.patch_std_streams() as (stdout, _):
         self.cmd._search(*args, **kwargs)
         call_args = self.base.output.matchcallback.call_args_list
         pkgs = [c[0][0] for c in call_args]
         return (stdout.getvalue(), pkgs)