Exemplo n.º 1
0
  def test_rabbitmqagent_ensure_after_execute_call_super(self, method):
    rmqagent = RabbitMqAgent({},{})

    rmq = Mock()
    rmqagent.rmqclient = rmq

    rmqagent.ensure_after_execute()

    method.assert_called_once_with(rmqagent)
Exemplo n.º 2
0
  def test_rabbitmqagent_ensure_after_execute(self):
    rmqagent = RabbitMqAgent({},{})

    rmq = Mock()
    rmqagent.rmqclient = rmq

    rmqagent.ensure_after_execute()

    rmq.disconnect.assert_called_once_with()
Exemplo n.º 3
0
  def test_rabbitmqagent_basicpublish(self):
    import json
    conf={"channel":{"exchange":"ex","type":"type"},"messages":{"routing_key":"rt"}}
    rmqagent = RabbitMqAgent(conf, {})

    rmq = Mock()
    rmqagent.rmqclient = rmq
    
    obj={"aa":1, "bb":{"cc":2}}
    rmqagent.basic_publish_json(obj)

    expected = {}
    expected["id"] = rmqagent.id
    expected["payload"] = obj
    message=json.dumps(expected)
    rmq.basic_publish_json.assert_called_once_with(conf["channel"]["exchange"], conf["channel"]["type"], conf["messages"]["routing_key"], expected)