示例#1
0
    def test_unknown_package(self):
        platform = Apk()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(1, [],
                                                b"Installed: Available:")

        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, "check_output")).mock
        mock_checkoutput.side_effect = _side_effect_raise

        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with(['apk', 'version', 'foo'],
                                                 stderr=subprocess.STDOUT)
        self.assertEqual(None, platform.get_pkg_version("foo"))
示例#2
0
    def test_unknown_package(self):
        platform = Apk()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(
                1, [], b"Installed: Available:")

        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, "check_output")).mock
        mock_checkoutput.side_effect = _side_effect_raise

        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with(
            ['apk', 'version', 'foo'],
            stderr=subprocess.STDOUT)
        self.assertEqual(None, platform.get_pkg_version("foo"))
示例#3
0
 def test_installed_version(self):
     platform = Apk()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, "check_output")).mock
     mock_checkoutput.return_value = b'Insd: Able: foo-4.0.0-r1 = 4.0.0-r1'
     self.assertEqual('4.0.0-r1', platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(['apk', 'version', 'foo'],
                                              stderr=subprocess.STDOUT)
示例#4
0
 def test_installed_version(self):
     platform = Pacman()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, "check_output")).mock
     mock_checkoutput.return_value = b'foo 4.0.0-2'
     self.assertEqual("4.0.0-2", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(['pacman', '-Q', 'foo'],
                                              stderr=subprocess.STDOUT)
示例#5
0
    def test_unknown_package(self):
        platform = Rpm()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(
                1, [], b"package foo is not installed\n")

        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock
        mock_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with(
            ["rpm", "--qf",
             "%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
             "--whatprovides", "-q", "foo"],
            stderr=subprocess.STDOUT)
        self.assertEqual(None, platform.get_pkg_version("foo"))
示例#6
0
 def test_installed_version(self):
     platform = Apk()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, "check_output")).mock
     mock_checkoutput.return_value = b'Insd: Able: foo-4.0.0-r1 = 4.0.0-r1'
     self.assertEqual('4.0.0-r1', platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(
         ['apk', 'version', 'foo'],
         stderr=subprocess.STDOUT)
示例#7
0
 def test_installed_version(self):
     platform = Pacman()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, "check_output")).mock
     mock_checkoutput.return_value = b'foo 4.0.0-2'
     self.assertEqual("4.0.0-2", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(
         ['pacman', '-Q', 'foo'],
         stderr=subprocess.STDOUT)
示例#8
0
 def test_installed_version(self):
     platform = Emerge()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, 'check_output',
                                  return_value=b"4.0.0\n")).mock
     self.assertEqual("4.0.0", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(
         ['equery', 'l', '--format=\'$version\'', 'foo'],
         stderr=subprocess.STDOUT)
示例#9
0
    def test_unknown_package(self):
        platform = Rpm()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(
                1, [], b"package foo is not installed\n")

        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock
        mock_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with([
            "rpm", "--qf",
            "%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
            "--whatprovides", "-q", "foo"
        ],
                                                 stderr=subprocess.STDOUT)
        self.assertEqual(None, platform.get_pkg_version("foo"))
示例#10
0
 def test_installed_version(self):
     platform = Emerge()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess,
                                  'check_output',
                                  return_value=b"4.0.0\n")).mock
     self.assertEqual("4.0.0", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(
         ['equery', 'l', '--format=\'$version\'', 'foo'],
         stderr=subprocess.STDOUT)
示例#11
0
 def test_installed_version(self):
     platform = Rpm()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess, 'check_output',
                                  return_value=b"foo 4.0.0-0.el6\n")).mock
     self.assertEqual("4.0.0-0.el6", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with(
         ["rpm", "--qf",
          "%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
          "--whatprovides", "-q", "foo"],
         stderr=subprocess.STDOUT)
示例#12
0
 def test_installed_version(self):
     platform = Dpkg()
     mocked_checkoutput = self.useFixture(
         fixtures.MockPatchObject(
             subprocess,
             'check_output',
             return_value=b"foo install ok installed 4.0.0-0ubuntu1\n")
     ).mock
     self.assertEqual("4.0.0-0ubuntu1", platform.get_pkg_version("foo"))
     mocked_checkoutput.assert_called_once_with(
         ["dpkg-query", "-W", "-f",
          "${Package} ${Status} ${Version}\n", "foo"],
         stderr=subprocess.STDOUT)
示例#13
0
 def test_installed_version(self):
     platform = Rpm()
     mock_checkoutput = self.useFixture(
         fixtures.MockPatchObject(subprocess,
                                  'check_output',
                                  return_value=b"foo 4.0.0-0.el6\n")).mock
     self.assertEqual("4.0.0-0.el6", platform.get_pkg_version("foo"))
     mock_checkoutput.assert_called_once_with([
         "rpm", "--qf",
         "%{NAME} %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\n",
         "--whatprovides", "-q", "foo"
     ],
                                              stderr=subprocess.STDOUT)
示例#14
0
    def test_unknown_package(self):
        platform = Emerge()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(3, [], '')

        mocked_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock

        mocked_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mocked_checkoutput.assert_called_once_with(
            ['equery', 'l', '--format=\'$version\'', 'foo'],
            stderr=subprocess.STDOUT)
示例#15
0
 def test_installed_version(self):
     platform = Dpkg()
     mocked_checkoutput = self.useFixture(
         fixtures.MockPatchObject(
             subprocess,
             'check_output',
             return_value=b"foo install ok installed 4.0.0-0ubuntu1\n")
     ).mock
     self.assertEqual("4.0.0-0ubuntu1", platform.get_pkg_version("foo"))
     mocked_checkoutput.assert_called_once_with([
         "dpkg-query", "-W", "-f", "${Package} ${Status} ${Version}\n",
         "foo"
     ],
                                                stderr=subprocess.STDOUT)
示例#16
0
    def test_unknown_package(self):
        platform = Emerge()

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(3, [], '')

        mocked_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock

        mocked_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mocked_checkoutput.assert_called_once_with(
            ['equery', 'l', '--format=\'$version\'', 'foo'],
            stderr=subprocess.STDOUT)
示例#17
0
    def test_unknown_package(self):
        platform = Dpkg()
        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(
                1, [], b"dpkg-query: no packages found matching foo\n")

        mock_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with(
            ["dpkg-query", "-W", "-f",
             "${Package} ${Status} ${Version}\n", "foo"],
            stderr=subprocess.STDOUT)
示例#18
0
    def test_unknown_package(self):
        platform = Dpkg()
        mock_checkoutput = self.useFixture(
            fixtures.MockPatchObject(subprocess, 'check_output')).mock

        def _side_effect_raise(*args, **kwargs):
            raise subprocess.CalledProcessError(
                1, [], b"dpkg-query: no packages found matching foo\n")

        mock_checkoutput.side_effect = _side_effect_raise
        self.assertEqual(None, platform.get_pkg_version("foo"))
        mock_checkoutput.assert_called_once_with([
            "dpkg-query", "-W", "-f", "${Package} ${Status} ${Version}\n",
            "foo"
        ],
                                                 stderr=subprocess.STDOUT)