def test_rollback_error(self): ''' Test suseconnect.rollback 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.rollback()
def test_rollback_error(self): """ Test suseconnect.rollback 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.rollback()
def test_rollback(self): ''' Test suseconnect.rollback without parameters ''' result = { 'retcode': 0, 'stdout': 'Starting to sync system product activations', } salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.rollback(), 'Starting to sync system product activations') salt_mock['cmd.run_all'].assert_called_with( ['SUSEConnect', '--rollback'])
def test_rollback(self): """ Test suseconnect.rollback without parameters """ result = { "retcode": 0, "stdout": "Starting to sync system product activations", } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.rollback(), "Starting to sync system product activations") salt_mock["cmd.run_all"].assert_called_with( ["SUSEConnect", "--rollback"])
def test_rollback_params(self): """ Test suseconnect.rollback with parameters """ result = { "retcode": 0, "stdout": "Starting to sync system product activations", } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual( suseconnect.rollback(url="https://scc.suse.com", root="/mnt"), "Starting to sync system product activations", ) salt_mock["cmd.run_all"].assert_called_with([ "SUSEConnect", "--rollback", "--url", "https://scc.suse.com", "--root", "/mnt", ])