def test_file_list(self): """ Test if it lists the files that belong to a package. """ dpkg_query_mock = MagicMock(return_value={ "retcode": 0, "stderr": "", "stdout": "installed\thostname" }) dpkg_L_mock = MagicMock(side_effect=self.dpkg_L_side_effect) with patch.dict(dpkg.__salt__, { "cmd.run_all": dpkg_query_mock, "cmd.run": dpkg_L_mock }): self.assertDictEqual( dpkg.file_list("hostname"), { "errors": [], "files": [ "/.", "/bin", "/bin/dnsdomainname", "/bin/domainname", "/bin/hostname", "/bin/nisdomainname", "/bin/ypdomainname", "/usr", "/usr/share", "/usr/share/doc", "/usr/share/doc/hostname", "/usr/share/doc/hostname/changelog.gz", "/usr/share/doc/hostname/copyright", "/usr/share/man", "/usr/share/man/man1", "/usr/share/man/man1/dnsdomainname.1.gz", "/usr/share/man/man1/domainname.1.gz", "/usr/share/man/man1/hostname.1.gz", "/usr/share/man/man1/nisdomainname.1.gz", "/usr/share/man/man1/ypdomainname.1.gz", ], }, ) mock = MagicMock(return_value={ "retcode": 1, "stderr": DPKG_ERROR_MSG, "stdout": "" }) with patch.dict(dpkg.__salt__, {"cmd.run_all": mock}): self.assertEqual(dpkg.file_list("httpd"), "Error: " + DPKG_ERROR_MSG)
def test_file_list(self): ''' Test if it lists the files that belong to a package. ''' mock = MagicMock(return_value={'retcode': 0, 'stderr': '', 'stdout': 'Salt'}) with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}): self.assertDictEqual(dpkg.file_list('httpd'), {'errors': [], 'files': []}) mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error', 'stdout': 'Salt'}) with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}): self.assertEqual(dpkg.file_list('httpd'), 'Error: error')
def test_file_list(self): """ Test if it lists the files that belong to a package. """ mock = MagicMock(return_value={ "retcode": 0, "stderr": "", "stdout": "Salt" }) with patch.dict(dpkg.__salt__, {"cmd.run_all": mock}): self.assertDictEqual(dpkg.file_list("httpd"), { "errors": [], "files": [] }) mock = MagicMock(return_value={ "retcode": 1, "stderr": "error", "stdout": "Salt" }) with patch.dict(dpkg.__salt__, {"cmd.run_all": mock}): self.assertEqual(dpkg.file_list("httpd"), "Error: error")