Beispiel #1
0
def test_send_msg():
    """
    Test to send a message to an XMPP user
    """
    ret = {"name": "salt", "changes": {}, "result": None, "comment": ""}
    with patch.dict(xmpp.__opts__, {"test": True}):
        ret.update({"comment": "Need to send message to myaccount: salt"})
        assert xmpp.send_msg("salt", "myaccount", "*****@*****.**") == ret

    with patch.dict(xmpp.__opts__, {"test": False}):
        mock = MagicMock(return_value=True)
        with patch.dict(
            xmpp.__salt__, {"xmpp.send_msg": mock, "xmpp.send_msg_multi": mock}
        ):
            ret.update({"result": True, "comment": "Sent message to myaccount: salt"})
            assert xmpp.send_msg("salt", "myaccount", "*****@*****.**") == ret
Beispiel #2
0
    def test_send_msg(self):
        '''
            Test to send a message to an XMPP user
        '''
        ret = {'name': 'salt',
               'changes': {},
               'result': None,
               'comment': ''}
        with patch.dict(xmpp.__opts__, {"test": True}):
            ret.update({'comment': 'Need to send message to myaccount: salt'})
            self.assertDictEqual(xmpp.send_msg('salt', 'myaccount',
                                               '*****@*****.**'), ret)

        with patch.dict(xmpp.__opts__, {"test": False}):
            mock = MagicMock(return_value=True)
            with patch.dict(xmpp.__salt__, {"xmpp.send_msg": mock}):
                ret.update({'result': True,
                            'comment': 'Sent message to myaccount: salt'})
                self.assertDictEqual(xmpp.send_msg('salt', 'myaccount',
                                                   '*****@*****.**'), ret)
Beispiel #3
0
    def test_send_msg(self):
        '''
            Test to send a message to an XMPP user
        '''
        ret = {'name': 'salt',
               'changes': {},
               'result': None,
               'comment': ''}
        with patch.dict(xmpp.__opts__, {"test": True}):
            ret.update({'comment': 'Need to send message to myaccount: salt'})
            self.assertDictEqual(xmpp.send_msg('salt', 'myaccount',
                                               '*****@*****.**'), ret)

        with patch.dict(xmpp.__opts__, {"test": False}):
            mock = MagicMock(return_value=True)
            with patch.dict(xmpp.__salt__, {'xmpp.send_msg': mock,
                                            'xmpp.send_msg_multi': mock}):
                ret.update({'result': True,
                            'comment': 'Sent message to myaccount: salt'})
                self.assertDictEqual(xmpp.send_msg('salt', 'myaccount',
                                                   '*****@*****.**'), ret)