def test_list_pkgs(self): ''' Test if it lists the packages currently installed ''' mock = MagicMock(return_value={'retcode': 0, 'stderr': '', 'stdout': 'Salt'}) with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}): self.assertDictEqual(dpkg.list_pkgs('httpd'), {}) mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error', 'stdout': 'Salt'}) with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}): self.assertEqual(dpkg.list_pkgs('httpd'), 'Error: error')