def test_send_message(self):
        name = 'salt'
        room_id = '123456'
        from_name = 'SuperAdmin'
        message = 'This state was executed successfully.'

        ret = {'name': name,
               'result': None,
               'comment': '',
               'changes': {}}

        with patch.dict(hipchat.__opts__, {'test': True}):
            comt = ('The following message is to be sent to Hipchat: {0}'
                    .format(message))
            ret.update({'comment': comt})
            self.assertDictEqual(hipchat.send_message(name, room_id, from_name,
                                                      message), ret)

        with patch.dict(hipchat.__opts__, {'test': False}):
            comt = ('Hipchat room id is missing: {0}'.format(name))
            ret.update({'comment': comt, 'result': False})
            self.assertDictEqual(hipchat.send_message(name, None, from_name,
                                                      message), ret)

            comt = ('Hipchat from name is missing: {0}'.format(name))
            ret.update({'comment': comt})
            self.assertDictEqual(hipchat.send_message(name, room_id, None,
                                                      message), ret)

            comt = ('Hipchat message is missing: {0}'.format(name))
            ret.update({'comment': comt})
            self.assertDictEqual(hipchat.send_message(name, room_id, from_name,
                                                      None), ret)

            mock = MagicMock(return_value=True)
            with patch.dict(hipchat.__salt__, {'hipchat.send_message': mock}):
                comt = ('Sent message: {0}'.format(name))
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(hipchat.send_message(name, room_id,
                                                          from_name, message),
                                     ret)
Test to send a message to a Hipchat room.
dataset/ETHPy150Open saltstack/salt/tests/unit/states/hipchat_test.py/HipchatTestCase.test_send_message