def test_computer_desc(self): ''' Test to manage the computer's description field ''' ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=['salt', 'stack', 'stack']) with patch.dict(win_system.__salt__, {"system.get_computer_desc": mock}): ret.update( {'comment': "Computer description" " already set to 'salt'"}) self.assertDictEqual(win_system.computer_desc('salt'), ret) with patch.dict(win_system.__opts__, {"test": True}): ret.update({ 'result': None, 'comment': "Computer description" " will be changed to 'salt'" }) self.assertDictEqual(win_system.computer_desc('salt'), ret) with patch.dict(win_system.__opts__, {"test": False}): mock = MagicMock(return_value={'Computer Description': 'nfs'}) with patch.dict(win_system.__salt__, {"system.set_computer_desc": mock}): ret.update({ 'result': False, 'comment': "Unable to set" " computer description to 'salt'" }) self.assertDictEqual(win_system.computer_desc('salt'), ret)
def test_computer_desc(self): """ Test to manage the computer's description field """ ret = {"name": "salt", "changes": {}, "result": True, "comment": ""} mock = MagicMock(side_effect=["salt", "stack", "stack"]) with patch.dict(win_system.__salt__, {"system.get_computer_desc": mock}): ret.update( {"comment": "Computer description" " already set to 'salt'"}) self.assertDictEqual(win_system.computer_desc("salt"), ret) with patch.dict(win_system.__opts__, {"test": True}): ret.update({ "result": None, "comment": "Computer description" " will be changed to 'salt'", }) self.assertDictEqual(win_system.computer_desc("salt"), ret) with patch.dict(win_system.__opts__, {"test": False}): mock = MagicMock(return_value={"Computer Description": "nfs"}) with patch.dict(win_system.__salt__, {"system.set_computer_desc": mock}): ret.update({ "result": False, "comment": "Unable to set" " computer description to 'salt'", }) self.assertDictEqual(win_system.computer_desc("salt"), ret)
def test_computer_desc(self): ''' Test to manage the computer's description field ''' ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=['salt', 'stack', 'stack']) with patch.dict(win_system.__salt__, {"system.get_computer_desc": mock}): ret.update({'comment': "Computer description" " already set to 'salt'"}) self.assertDictEqual(win_system.computer_desc('salt'), ret) with patch.dict(win_system.__opts__, {"test": True}): ret.update({'result': None, 'comment': "Computer description" " will be changed to 'salt'"}) self.assertDictEqual(win_system.computer_desc('salt'), ret) with patch.dict(win_system.__opts__, {"test": False}): mock = MagicMock(return_value={'Computer Description': 'nfs'}) with patch.dict(win_system.__salt__, {"system.set_computer_desc": mock}): ret.update({'result': False, 'comment': "Unable to set" " computer description to 'salt'"}) self.assertDictEqual(win_system.computer_desc('salt'), ret)