Example #1
0
    def test_serve_expects_handler_for_given_route(self):
        self.setUpBind()

        self.socket.recv = mock.MagicMock(side_effect=results('route', 'msg'))
        z = Zmq(context=self.ctx)
        self.assertRaises(KeyError, z.serve)

        expected = [mock.call(), mock.call()]
        self.assertEqual(self.socket.recv.call_args_list, expected)
Example #2
0
    def test_send_passes_response_from_socket_recv_to_deferred_resolve(self):
        self.setUpConnect()
        self.socket.recv = mock.MagicMock(return_value = 'resp')

        Zmq(context=self.ctx).connect().send('route', 'message',
                self.deferred)

        expected = [mock.call(IsA(str), IsA(int)), mock.call(IsA(str))]
        self.assertEqual(self.socket.send.call_args_list, expected)
        self.socket.recv.assert_called_once_with()
        self.deferred.resolve.assert_called_once_with('resp')
Example #3
0
 def test_reject_can_by_called_once(self):
     expected = [mock.call(1), mock.call(1), mock.call(1)]
     Deferred().fail(self.c).reject(1).fail(self.c).reject(2).fail(self.c)
     self.assertEqual(self.c.call_args_list, expected)
Example #4
0
 def test_object_can_be_resolved_once(self):
     expected = [mock.call(1), mock.call(1)]
     CallbackList().done(self.c).resolve(1).resolve(2).done(self.c)
     self.assertEqual(self.c.call_args_list, expected)
Example #5
0
    def test_resolve_can_by_called_once(self):
        expected = [mock.call(1), mock.call(1), mock.call(1)]

        Deferred().done(self.c).resolve(1).done(self.c).resolve(2).done(self.c)

        self.assertEqual(self.c.call_args_list, expected)