Exemplo n.º 1
0
    def test_send_and_recv(self, mocker):
        msg = BatsimMessage(0)
        mocker.patch.object(protocol.zmq.Socket, 'recv_json', return_value=msg)

        p = NetworkHandler("tcp://localhost:28000")
        p.bind()

        m = p.send_and_recv(msg)

        assert m == msg
        protocol.zmq.Socket.recv_json.assert_called_once()
        protocol.zmq.Socket.send_json.assert_called_once_with(msg.to_json())
Exemplo n.º 2
0
    def test_to_json_must_include_requests_only(self):
        events = [
            RequestedCallBatsimEvent(15),
            KillJobBatsimRequest(10, "w!1", "w!2")
        ]
        m = BatsimMessage(15, events)

        events_json = [
            BatsimRequestAPI.get_kill_job(10, ["w!1", "w!2"]),
        ]

        m_jsn = BatsimAPI.get_message(15, events_json)
        assert m.to_json() == m_jsn
Exemplo n.º 3
0
 def test_send(self):
     msg = BatsimMessage(0)
     p = NetworkHandler("tcp://localhost:28000")
     p.bind()
     p.send(msg)
     protocol.zmq.Socket.send_json.assert_called_once_with(msg.to_json())