def test_send_message(self):
     with mock.patch('mcollective.Client') as mocked:
         rpc = SimpleRPC(
             agent='foo',
             action='bar',
             config=TEST_CFG,
         )
         rpc.send(ham='eggs')
         put = rpc.stomp_client.put
         put.assert_called()
    def test_send_message(self):

        with mock.patch('mcollective.Client') as mocked:
            instance = mocked.return_value
            instance.get_nowait = mock.Mock(side_effect=stompy.Empty)
            rpc = SimpleRPC(
                agent='foo',
                action='bar',
                config=self.cfg,
            )
            rpc.send(ham='eggs')
            put = rpc.stomp_client.put
            put.assert_called()
Esempio n. 3
0
 def stop_service(self, service_name, id):
     filter = Filter().add_identity(id)
     cmd = "stop service=%s"%(service_name)
     msg = Message(body=cmd, agent='service', config=self.config, filter=filter)
     action = SimpleRPCAction(config=self.config, msg=msg, agent='service')
     logger.info(action.call())
Esempio n. 4
0
 def runonce_puppet(self, id):
     filter = Filter().add_identity(id)
     msg = Message(body='runonce', agent='puppet', config=self.config, filter=filter)
     action = SimpleRPCAction(config=self.config, msg=msg, agent='puppet')
     logger.info(action.call())