Exemple #1
0
 def test_install_installed(self):
     """Test that nothing changes if an installed package matches."""
     stdout = dnf.pycomp.StringIO()
     with support.wiretap_logs("dnf", logging.WARNING, stdout):
         self.base.install("librita")
     self.assertEqual(self.base.goal.req_length(), 0)
     self.assertIn("Package librita-1-1.x86_64 is already installed, skipping.", stdout.getvalue())
Exemple #2
0
 def test_install_installed(self):
     """Test that nothing changes if an installed package matches."""
     stdout = dnf.pycomp.StringIO()
     with support.wiretap_logs('dnf', logging.WARNING, stdout):
         self.base.install('librita')
     self.assertEqual(self.base.goal.req_length(), 0)
     self.assertIn(
         'Package librita-1-1.x86_64 is already installed, skipping.',
         stdout.getvalue())
Exemple #3
0
 def test_install_unavailable(self):
     """Test that nothing changes if an unavailable package matches."""
     stdout = dnf.pycomp.StringIO()
     with support.wiretap_logs("dnf", logging.WARNING, stdout):
         cnt = self.base.install("hole")
     self.assertEqual(cnt, 1)
     installed_pkgs = self.base.sack.query().installed().run()
     self.assertResult(self.base, installed_pkgs)
     self.assertIn("Package hole-1-1.x86_64 is already installed, skipping.", stdout.getvalue())
Exemple #4
0
    def test_run_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs("dnf", logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, support.command_run, self.cmd, ["non-existent"])

        self.assertEqual(stdout.getvalue(), "No match for argument: non-existent\n")
        self.assertResult(self.cmd.base, self.cmd.base.sack.query().installed())
Exemple #5
0
    def test_install_name_choice(self):
        """Test that the matching pkg that can be installed is installed."""
        # Don't install the SRPM.
        self.base.sack.add_excludes(dnf.subject.Subject("pepper.src").get_best_query(self.base.sack))

        stdout = dnf.pycomp.StringIO()
        with support.wiretap_logs("dnf", logging.WARNING, stdout):
            self.base.install("pepper")
        self.assertEqual(self.base.goal.req_length(), 0)
        self.assertIn("Package pepper-20-0.x86_64 is already installed, skipping.", stdout.getvalue())
Exemple #6
0
    def test_run_notinstalled(self):
        """Test whether it fails if the package is not installed."""
        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(stdout.getvalue(), 'No match for argument: lotus\n')
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #7
0
    def test_run_notinstalled(self):
        """Test whether it fails if the package is not installed."""
        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(stdout.getvalue(), 'No match for argument: lotus\n')
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #8
0
 def test_install_installed(self):
     """Test that nothing changes if an installed package matches."""
     stdout = dnf.pycomp.StringIO()
     with support.wiretap_logs('dnf', logging.WARNING, stdout):
         self.base.install('librita')
     installed, removed = self.installed_removed(self.base)
     self.assertEmpty(installed)
     self.assertEmpty(removed)
     self.assertIn(
         'Package librita-1-1.x86_64 is already installed, skipping.',
         stdout.getvalue())
Exemple #9
0
    def test_run_on_repo_all_notinstalled(self):
        """Test running with a repository from which nothing is installed."""
        stdout = dnf.pycomp.StringIO()

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, support.command_run, cmd,
                              ['non-distro', 'remove-or-distro-sync'])

        self.assertIn('No package installed from the repository.\n',
                      stdout.getvalue(), 'mismatch not logged')
Exemple #10
0
 def test_install_unavailable(self):
     """Test that nothing changes if an unavailable package matches."""
     stdout = dnf.pycomp.StringIO()
     with support.wiretap_logs('dnf', logging.WARNING, stdout):
         cnt = self.base.install('hole')
     self.assertEqual(cnt, 1)
     installed_pkgs = self.base.sack.query().installed().run()
     self.assertResult(self.base, installed_pkgs)
     self.assertIn(
         'Package hole-1-1.x86_64 is already installed, skipping.',
         stdout.getvalue())
Exemple #11
0
    def test_updatePkgs_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              self.cmd.run, ['non-existent'])

        self.assertEqual(stdout.getvalue(),
                         'No match for argument: non-existent\n')
        self.assertResult(self.cmd.base, self.cmd.base.sack.query().installed())
Exemple #12
0
    def test_run_package_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(stdout.getvalue(),
                         'No package non-existent available.\n')
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #13
0
    def test_run_group_notfound(self):
        """Test whether it fails if the group cannot be found."""
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              support.command_run, self._cmd, ['@non-existent'])

        self.assertEqual(stdout.getvalue(),
                         "Warning: Group 'non-existent' does not exist.\n")
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #14
0
    def test_run_on_repo_spec_notinstalled(self):
        """Test running with a package which is not installed."""
        stdout = dnf.pycomp.StringIO()

        cmd = dnf.cli.commands.RepoPkgsCommand.RemoveOrDistroSyncSubCommand(
            self.cli)
        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, cmd.run_on_repo,
                              'non-distro', ['not-installed'])

        self.assertIn('No match for argument: not-installed\n',
                      stdout.getvalue(), 'mismatch not logged')
Exemple #15
0
    def test_run_group_notfound(self):
        """Test whether it fails if the group cannot be found."""
        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(stdout.getvalue(),
                         "Warning: Group 'non-existent' does not exist.\n")
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #16
0
    def test_run_package_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

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

        self.assertEqual(stdout.getvalue(),
                         'No package non-existent available.\n')
        self.assertResult(self._cmd.cli.base,
                          self._cmd.cli.base.sack.query().installed())
Exemple #17
0
    def test_run_on_repo_spec_notinstalled(self):
        """Test running with a package which is not installed."""
        stdout = dnf.pycomp.StringIO()

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              support.command_run, cmd,
                              ['non-distro', 'remove-or-distro-sync', 'not-installed'])

        self.assertIn('No match for argument: not-installed\n', stdout.getvalue(),
                      'mismatch not logged')
Exemple #18
0
    def test_run_on_repo_all_notinstalled(self):
        """Test running with a repository from which nothing is installed."""
        stdout = dnf.pycomp.StringIO()

        cmd = dnf.cli.commands.RepoPkgsCommand(self.cli)
        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              support.command_run, cmd,
                              ['non-distro', 'remove-or-distro-sync'])

        self.assertIn('No package installed from the repository.\n',
                      stdout.getvalue(), 'mismatch not logged')
Exemple #19
0
    def test_install_name_choice(self):
        """Test that the matching pkg that can be installed is installed."""
        # Don't install the SRPM.
        self.base.sack.add_excludes(
            dnf.subject.Subject('pepper.src').get_best_query(self.base.sack))

        stdout = dnf.pycomp.StringIO()
        with support.wiretap_logs('dnf', logging.WARNING, stdout):
            self.base.install('pepper')
        self.assertEqual(self.base.goal.req_length(), 0)
        self.assertIn(
            'Package pepper-20-0.x86_64 is already installed, skipping.',
            stdout.getvalue())
Exemple #20
0
    def test_run_package_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              support.command_run, self._cmd, ['non-existent', 'lotus'])

        self.assertEqual(stdout.getvalue(),
                         'No package non-existent available.\n')
        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)))
Exemple #21
0
    def test_install_name_choice(self):
        """Test that the matching pkg that can be installed is installed."""
        # Don't install the SRPM.
        self.base.sack.add_excludes(
            dnf.subject.Subject('pepper.src').get_best_query(self.base.sack))

        stdout = dnf.pycomp.StringIO()
        with support.wiretap_logs('dnf', logging.WARNING, stdout):
            self.base.install('pepper')
        installed, removed = self.installed_removed(self.base)
        self.assertEmpty(installed | removed)
        self.assertIn(
            'Package pepper-20-0.x86_64 is already installed, skipping.',
            stdout.getvalue())
Exemple #22
0
    def test_run_package_notfound(self):
        """Test whether it fails if the package cannot be found."""
        stdout = dnf.pycomp.StringIO()

        with support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error,
                              support.command_run, self._cmd, ['non-existent', 'lotus'])

        self.assertEqual(stdout.getvalue(),
                         'No package non-existent available.\n')
        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)))
Exemple #23
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, 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())
Exemple #24
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())
Exemple #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 support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, 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())
Exemple #26
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 support.wiretap_logs('dnf', logging.INFO, stdout):
            self.assertRaises(dnf.exceptions.Error, 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())