Example #1
0
    def test_list_pkgs(self):
        """
        Test if it lists the packages currently installed
        """
        mock = MagicMock(
            return_value={
                "retcode": 0,
                "stderr": "",
                "stdout": "installed\thostname\t3.21",
            }
        )
        with patch.dict(dpkg.__salt__, {"cmd.run_all": mock}):
            self.assertDictEqual(dpkg.list_pkgs("hostname"), {"hostname": "3.21"})

        mock = MagicMock(
            return_value={
                "retcode": 1,
                "stderr": "dpkg-query: no packages found matching httpd",
                "stdout": "",
            }
        )
        with patch.dict(dpkg.__salt__, {"cmd.run_all": mock}):
            self.assertEqual(
                dpkg.list_pkgs("httpd"),
                "Error:  dpkg-query: no packages found matching httpd",
            )
Example #2
0
    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')
Example #3
0
    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")