def test_cleanup_error(self): ''' Test suseconnect.cleanup 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.cleanup()
def test_cleanup_error(self): """ Test suseconnect.cleanup 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.cleanup()
def test_cleanup(self): ''' Test suseconnect.cleanup without parameters ''' result = {'retcode': 0, 'stdout': 'Service has been removed'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.cleanup(), 'Service has been removed') salt_mock['cmd.run_all'].assert_called_with( ['SUSEConnect', '--cleanup'])
def test_cleanup(self): """ Test suseconnect.cleanup without parameters """ result = {"retcode": 0, "stdout": "Service has been removed"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.cleanup(), "Service has been removed") salt_mock["cmd.run_all"].assert_called_with( ["SUSEConnect", "--cleanup"])