def test_installed(self): runresult = RunResult() runresult.return_code = 0 runresult.stdout = "Status: install ok installed\n" node = MagicMock() node.run.return_value = runresult self.assertTrue(pkg_apt.pkg_installed(node, "foo"))
def test_not_installed(self): runresult = RunResult() runresult.return_code = 1 runresult.stdout = ( "Package `foo' is not installed and no info is available.\n" "Use dpkg --info (= dpkg-deb --info) to examine archive files,\n" "and dpkg --contents (= dpkg-deb --contents) to list their contents.\n" ) node = MagicMock() node.run.return_value = runresult self.assertFalse(pkg_apt.pkg_installed(node, "foo"))