def test_jsonify(self, sendMessage):
    now = datetime.datetime.now()

    p = PubSubProtocol()
    p.send("foo", now)

    args, kwargs = sendMessage.call_args
    actual = json.loads(args[0].decode('utf8'))

    expected = {"topic": "foo", "data": now.isoformat()}

    self.assertEqual(actual, expected)
Example #2
0
    def test_jsonify(self, send_message):
        now = datetime.datetime.now()

        p = PubSubProtocol()
        p.send("foo", now)

        args, kwargs = send_message.call_args
        actual = json.loads(args[0].decode('utf8'))

        expected = {"topic": "foo", "data": now.isoformat()}

        self.assertEqual(actual, expected)
  def test_bogus_payload(self, sendMessage):
    p = PubSubProtocol()
    p.send("topic", p)
    p.send(p, {'data': 'bar'})
    p.send(p, p)

    self.assertFalse(sendMessage.called)
Example #4
0
    def test_bogus_payload(self, send_message):
        p = PubSubProtocol()
        p.send("topic", p)
        p.send(p, {'data': 'bar'})
        p.send(p, p)

        self.assertFalse(send_message.called)
 def test_send_message(self, sendMessage):
   p = PubSubProtocol()
   p.send("foo", "bar")
   self.assertEqual(sendMessage.call_count, 1)
Example #6
0
 def test_send_message(self, send_message):
     p = PubSubProtocol()
     p.send("foo", "bar")
     self.assertEqual(send_message.call_count, 1)