def test_status_error(self): ''' Test suseconnect.status error ''' result = {'retcode': 1, 'stdout': 'Some Error', 'stderr': ''} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): with self.assertRaises(CommandExecutionError): suseconnect.status()
def test_status_error(self): """ Test suseconnect.status error """ result = {"retcode": 1, "stdout": "Some Error", "stderr": ""} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): with self.assertRaises(CommandExecutionError): suseconnect.status()
def test_status_params(self): """ Test suseconnect.status with parameters """ result = { "retcode": 0, "stdout": '[{"identifier":"SLES","version":"15.2",' '"arch":"x86_64","status":"No Registered"}]', } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual( suseconnect.status(root="/mnt"), [{ "identifier": "SLES", "version": "15.2", "arch": "x86_64", "status": "No Registered", }], ) salt_mock["cmd.run_all"].assert_called_with( ["SUSEConnect", "--status", "--root", "/mnt"])
def test_status(self): ''' Test suseconnect.status without parameters ''' result = { 'retcode': 0, 'stdout': '[{"identifier":"SLES","version":"15.2",' '"arch":"x86_64","status":"No Registered"}]', } salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.status(), [{ 'identifier': 'SLES', 'version': '15.2', 'arch': 'x86_64', 'status': 'No Registered', }]) salt_mock['cmd.run_all'].assert_called_with( ['SUSEConnect', '--status'])