Esempio n. 1
0
 def test_module_ping_client(self):
     """
     Ensure the function from main module pings clients correctly.
     """
     daemon = client.ensure_client_daemon()
     response = events.ping_client(daemon.get_port())
     self.assertIsNotNone(response)
     self.assertEqual(EventResponse.OK, response.status,
                      'Wrong response status.')
Esempio n. 2
0
 def test_client_replies_ping(self):
     """
     Ensure clients reply to a ping.
     """
     daemon = client.ensure_client_daemon()
     port = daemon.get_port()
     request = PingRequest()
     service = RpcService(EventsClientService_Stub, port, 'localhost')
     response = service.ping(request, timeout=1000)
     self.assertEqual(EventResponse.OK, response.status,
                      'Wrong response status.')
Esempio n. 3
0
    def test_async_ping_client(self):
        """
        Test asynchronous pinging of client.
        """
        flag = Mock()

        # executed after async signal, when response is received from server
        def reqcbk(request, response):
            flag(response.status)

        daemon = client.ensure_client_daemon()
        result = events.ping_client(daemon.get_port(), reqcbk=reqcbk)
        self.assertIsNone(result)
        time.sleep(1)  # wait for response to arrive from server.
        flag.assert_called_once_with(EventResponse.OK)