def test_repoid_option(self):
     args = ["--repo", "main"]
     self.cmd.base.repos.add(dnf.repo.Repo(name="main"))
     self.cmd.base.repos.add(dnf.repo.Repo(name="main_fail"))
     support.command_configure(self.cmd, args)
     repos = [repo.id for repo in self.cmd.base.repos.iter_enabled()]
     self.assertEqual(["main"], repos)
Пример #2
0
 def test_filelist(self):
     self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['-l'])
     pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
     self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
                      EXPECTED_FILELIST_FORMAT)
Пример #3
0
 def test_parse_args(self):
     args = '-p /become/legend --repo=silver --repo=screen'.split()
     self.cmd.base.repos.add(dnf.repo.Repo('silver'))
     self.cmd.base.repos.add(dnf.repo.Repo('screen'))
     support.command_configure(self.cmd, args)
     self.assertEqual(self.cmd.opts.repo, ['silver', 'screen'])
     self.assertEqual(self.cmd.opts.download_path, '/become/legend')
Пример #4
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)
Пример #5
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)
Пример #6
0
 def test_filelist(self):
     self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['-l'])
     pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
     self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
                      EXPECTED_FILELIST_FORMAT)
Пример #7
0
 def test_info(self):
     self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['--source'])
     pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
     self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
                      EXPECTED_SOURCERPM_FORMAT)
Пример #8
0
 def test_info(self):
     self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
         support.CliStub(support.BaseCliStub()))
     support.command_configure(self.cmd, ['--source'])
     pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
     self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
                      EXPECTED_SOURCERPM_FORMAT)
Пример #9
0
 def test_repoid_option(self):
     args = ["--repo", "main"]
     self.cmd.base.repos.add(support.RepoStub("main"))
     self.cmd.base.repos.add(support.RepoStub("main_fail"))
     support.command_configure(self.cmd, args)
     repos = [repo.id for repo in self.cmd.base.repos.iter_enabled()]
     self.assertEqual(["main"], repos)
Пример #10
0
 def test_history_convert_tids(self):
     """Test history _convert_tids()."""
     cmd = dnf.cli.commands.HistoryCommand(self.cli)
     cmd.cli.base.output = mock.MagicMock()
     cmd.cli.base.output.history.last().tid = 123
     cmd.cli.base.output.history.search = mock.MagicMock(return_value=[99])
     support.command_configure(cmd, ['list', '1..5', 'last', 'last-10', 'kernel'])
     self.assertEqual(cmd._convert_tids(), [1, 2, 3, 4, 5, 99, 113, 123])
Пример #11
0
 def test_parse_args(self):
     cli = support.CliStub(support.BaseCliStub())
     cli.base.repos.add(support.RepoStub('silver'))
     cli.base.repos.add(support.RepoStub('screen'))
     cmd = reposync.RepoSyncCommand(cli)
     args = '-p /become/legend --repo=silver --repo=screen'.split()
     support.command_configure(cmd, args)
     self.assertEqual(cmd.opts.repo, ['silver', 'screen'])
     self.assertEqual(cmd.opts.download_path, '/become/legend')
Пример #12
0
 def test_parse_args(self):
     cli = support.CliStub(support.BaseCliStub())
     cli.base.repos.add(dnf.repo.Repo(name='silver'))
     cli.base.repos.add(dnf.repo.Repo(name='screen'))
     cmd = reposync.RepoSyncCommand(cli)
     args = '-p /become/legend --repo=silver --repo=screen'.split()
     support.command_configure(cmd, args)
     self.assertEqual(cmd.opts.repo, ['silver', 'screen'])
     self.assertEqual(cmd.opts.download_path, '/become/legend')
Пример #13
0
    def test_history_get_error_output_undo_transactioncheckerror(self):
        """Test get_error_output with the history undo and a TransactionCheckError."""
        cmd = dnf.cli.commands.HistoryCommand(self.cli)
        support.command_configure(cmd, ['undo', '1'])

        lines = cmd.get_error_output(dnf.exceptions.TransactionCheckError())

        self.assertEqual(
            lines, ('Cannot undo transaction 1, doing so would result in an '
                    'inconsistent package database.', ))
Пример #14
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)
Пример #15
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)
Пример #16
0
    def test_history_get_error_output_undo_transactioncheckerror(self):
        """Test get_error_output with the history undo and a TransactionCheckError."""
        cmd = dnf.cli.commands.HistoryCommand(self.cli)
        support.command_configure(cmd, ['undo', '1'])

        lines = cmd.get_error_output(dnf.exceptions.TransactionCheckError())

        self.assertEqual(
            lines,
            ('Cannot undo transaction 1, doing so would result in an '
             'inconsistent package database.',))
Пример #17
0
    def test_pkg_download_path(self):
        args = '-p /become/legend'.split()
        repo = support.RepoStub('silver')
        support.command_configure(self.cmd, args)
        pkg = support.PkgStub('foo',
                              '0',
                              '1.0',
                              '1',
                              'noarch',
                              'silver',
                              repo=repo,
                              location="foo-0-1.0-1.noarch.rpm")

        pkgpath = self.cmd.pkg_download_path(pkg)
        self.assertEqual(pkgpath,
                         '/become/legend/silver/foo-0-1.0-1.noarch.rpm')

        pkg.location = "../pool/foo-0-1.0-1.noarch.rpm"
        with self.assertRaises(dnf.exceptions.Error):
            self.cmd.pkg_download_path(pkg)
Пример #18
0
 def test_parse(self):
     support.command_configure(self.cmd, ['--whatrequires', 'prudence'])
     self.assertIsNone(self.cmd.opts.whatprovides)
     self.assertEqual(self.cmd.opts.whatrequires, 'prudence')
     self.assertEqual(self.cmd.opts.queryformat,
                      dnf.cli.commands.repoquery.QFORMAT_DEFAULT)
Пример #19
0
 def test_conflict(self):
     with self.assertRaises(SystemExit) as exit:
         command_configure(self.cmd, ['--conflicts', '%{name}', '--provides'])
     self.assertEqual(exit.exception.code, 1)
Пример #20
0
 def test_metadata_target_default(self):
     args = '-p /become/legend'.split()
     repo = support.RepoStub('silver')
     support.command_configure(self.cmd, args)
     metadata_path = self.cmd.metadata_target(repo)
     self.assertEqual(metadata_path, '/become/legend/silver')
Пример #21
0
 def test_file(self):
     support.command_configure(self.cmd, ['/var/foobar'])
     self.assertIsNone(self.cmd.opts.file)
Пример #22
0
 def test_options(self):
     for arg in ('conflicts', 'enhances', 'obsoletes', 'provides',
                 'recommends', 'requires', 'suggests', 'supplements'):
         support.command_configure(self.cmd, ['--' + arg])
         self.assertEqual(self.cmd.opts.packageatr, arg)
Пример #23
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)
Пример #24
0
 def test_configure(self):
     with mock.patch('builddep.BuildDepCommand.base', MockBase()) as base:
         support.command_configure(self.cmd, ['tour'])
         self.assertTrue(self.cmd.cli.demands.available_repos)
Пример #25
0
 def test_configure(self):
     with mock.patch('builddep.BuildDepCommand.base', MockBase()) as base:
         support.command_configure(self.cmd, ['tour'])
         self.assertTrue(self.cmd.cli.demands.available_repos)
Пример #26
0
 def test_file(self):
     support.command_configure(self.cmd, ['/var/foobar'])
     self.assertIsNone(self.cmd.opts.file)
Пример #27
0
 def test_metadata_target_given(self):
     args = '-p /become/legend --metadata-path=/the/president'.split()
     repo = support.RepoStub('silver')
     support.command_configure(self.cmd, args)
     metadata_path = self.cmd.metadata_target(repo)
     self.assertEqual(metadata_path, '/the/president/silver')
Пример #28
0
 def test_configure(self):
     cli = self._cmd.cli
     support.command_configure(self._cmd, ['pkg'])
     self.assertFalse(cli.demands.allow_erasing)
     self.assertTrue(cli.demands.sack_activation)
Пример #29
0
 def test_configure_badargs(self):
     """Test whether the command fail in case of wrong args."""
     with self.assertRaises(SystemExit) as exit, \
          mock.patch('sys.stdout') as stdout:
          support.command_configure(self.cmd, [])
     self.assertEqual(exit.exception.code, 1)
Пример #30
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)
Пример #31
0
 def test_parse(self):
     support.command_configure(self.cmd, ['--whatrequires', 'prudence'])
     self.assertIsNone(self.cmd.opts.whatprovides)
     self.assertEqual(self.cmd.opts.whatrequires, 'prudence')
     self.assertEqual(self.cmd.opts.queryformat,
                      dnf.cli.commands.repoquery.QFORMAT_DEFAULT)
Пример #32
0
 def test_options(self):
     for arg in ('conflicts', 'enhances', 'obsoletes', 'provides',
                 'recommends', 'requires', 'suggests', 'supplements'):
         support.command_configure(self.cmd, ['--' + arg])
         self.assertEqual(self.cmd.opts.packageatr, arg)
Пример #33
0
 def test_configure(self):
     support.command_configure(self.cmd, ['remove', 'crack'])
     demands = self.cmd.cli.demands
     self.assertTrue(demands.allow_erasing)
     self.assertFalse(demands.freshest_metadata)
Пример #34
0
 def test_configure(self):
     cli = self._cmd.cli
     support.command_configure(self._cmd, ['pkg'])
     self.assertFalse(cli.demands.allow_erasing)
     self.assertTrue(cli.demands.sack_activation)
Пример #35
0
 def test_configure(self):
     support.command_configure(self.cmd, ['remove', 'crack'])
     demands = self.cmd.cli.demands
     self.assertTrue(demands.allow_erasing)
     self.assertFalse(demands.freshest_metadata)