def test_auto(self): ''' Test to instruct alternatives to use the highest priority path for <name> ''' name = 'pager' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[' auto mode', ' ', ' ']) mock_auto = MagicMock(return_value=True) with patch.dict(alternatives.__salt__, {'alternatives.display': mock, 'alternatives.auto': mock_auto}): comt = ('{0} already in auto mode'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(alternatives.auto(name), ret) comt = ('{0} will be put in auto mode'.format(name)) ret.update({'comment': comt, 'result': None}) with patch.dict(alternatives.__opts__, {'test': True}): self.assertDictEqual(alternatives.auto(name), ret) ret.update({'comment': '', 'result': True, 'changes': {'result': True}}) with patch.dict(alternatives.__opts__, {'test': False}): self.assertDictEqual(alternatives.auto(name), ret)
def test_auto(self): ''' Test to instruct alternatives to use the highest priority path for <name> ''' name = 'pager' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[' auto mode', ' ', ' ']) mock_auto = MagicMock(return_value=True) with patch.dict(alternatives.__salt__, { 'alternatives.display': mock, 'alternatives.auto': mock_auto }): comt = ('{0} already in auto mode'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(alternatives.auto(name), ret) comt = ('{0} will be put in auto mode'.format(name)) ret.update({'comment': comt, 'result': None}) with patch.dict(alternatives.__opts__, {'test': True}): self.assertDictEqual(alternatives.auto(name), ret) ret.update({ 'comment': '', 'result': True, 'changes': { 'result': True } }) with patch.dict(alternatives.__opts__, {'test': False}): self.assertDictEqual(alternatives.auto(name), ret)
def test_auto(): """ Test to instruct alternatives to use the highest priority path for <name> """ name = "pager" ret = {"name": name, "result": True, "changes": {}, "comment": ""} mock = MagicMock(side_effect=[" auto mode", " ", " "]) mock_auto = MagicMock(return_value=True) with patch.dict( alternatives.__salt__, {"alternatives.display": mock, "alternatives.auto": mock_auto}, ): comt = "{} already in auto mode".format(name) ret.update({"comment": comt}) assert alternatives.auto(name) == ret comt = "{} will be put in auto mode".format(name) ret.update({"comment": comt, "result": None}) with patch.dict(alternatives.__opts__, {"test": True}): assert alternatives.auto(name) == ret ret.update({"comment": "", "result": True, "changes": {"result": True}}) with patch.dict(alternatives.__opts__, {"test": False}): assert alternatives.auto(name) == ret