Esempio n. 1
0
 def test_installed_version(self):
     platform = Dpkg()
     mocker = mox.Mox()
     mocker.StubOutWithMock(subprocess, "check_output")
     subprocess.check_output(
         ["dpkg-query", "-W", "-f",
          "${binary:Package} ${Status} ${Version}\n", "foo"],
         stderr=subprocess.STDOUT).AndReturn(
             "foo install ok installed 4.0.0-0ubuntu1\n")
     mocker.ReplayAll()
     self.addCleanup(mocker.VerifyAll)
     self.addCleanup(mocker.UnsetStubs)
     self.assertEqual("4.0.0-0ubuntu1", platform.get_pkg_version("foo"))
Esempio n. 2
0
 def test_unknown_package(self):
     platform = Dpkg()
     mocker = mox.Mox()
     mocker.StubOutWithMock(subprocess, "check_output")
     subprocess.check_output(
         ["dpkg-query", "-W", "-f",
          "${binary:Package} ${Status} ${Version}\n", "foo"],
         stderr=subprocess.STDOUT).AndRaise(
             subprocess.CalledProcessError(
                 1, [], "dpkg-query: no packages found matching foo\n"))
     mocker.ReplayAll()
     self.addCleanup(mocker.VerifyAll)
     self.addCleanup(mocker.UnsetStubs)
     self.assertEqual(None, platform.get_pkg_version("foo"))
Esempio n. 3
0
 def test_installed_version(self):
     platform = Dpkg()
     mocker = mox.Mox()
     mocker.StubOutWithMock(subprocess, "check_output")
     subprocess.check_output(
         [
             "dpkg-query", "-W", "-f",
             "${binary:Package} ${Status} ${Version}\n", "foo"
         ],
         stderr=subprocess.STDOUT).AndReturn(
             "foo install ok installed 4.0.0-0ubuntu1\n")
     mocker.ReplayAll()
     self.addCleanup(mocker.VerifyAll)
     self.addCleanup(mocker.UnsetStubs)
     self.assertEqual("4.0.0-0ubuntu1", platform.get_pkg_version("foo"))
Esempio n. 4
0
 def test_unknown_package(self):
     platform = Dpkg()
     mocker = mox.Mox()
     mocker.StubOutWithMock(subprocess, "check_output")
     subprocess.check_output(
         [
             "dpkg-query", "-W", "-f",
             "${binary:Package} ${Status} ${Version}\n", "foo"
         ],
         stderr=subprocess.STDOUT).AndRaise(
             subprocess.CalledProcessError(
                 1, [], "dpkg-query: no packages found matching foo\n"))
     mocker.ReplayAll()
     self.addCleanup(mocker.VerifyAll)
     self.addCleanup(mocker.UnsetStubs)
     self.assertEqual(None, platform.get_pkg_version("foo"))