def test_present_set_target(self):
        name = 'saltdude'
        target = 'dude@saltstack.com'
        ret = {'comment': 'Set email alias {0} -> {1}'.format(name, target),
               'changes': {'alias': name},
               'name': name,
               'result': True}

        has_target = MagicMock(return_value=False)
        set_target = MagicMock(return_value=True)
        with patch.dict(alias.__salt__, {'aliases.has_target': has_target}):
            with patch.dict(alias.__opts__, {'test': False}):
                with patch.dict(alias.__salt__, {'aliases.set_target': set_target}):
                    self.assertEqual(alias.present(name, target), ret)
test alias.present set target
dataset/ETHPy150Open saltstack/salt/tests/unit/states/alias_test.py/AliasTest.test_present_set_target