Example #1
0
 def test_loop_starts(self):
     process = Mock(spawn = lambda x: x())
     client = ClientComms("c", process)
     client.send_loop = Mock()
     client.start_recv_loop = Mock()
     client.log_exception = Mock()
     client.start()
     client.send_loop.assert_called_once_with()
     client.start_recv_loop.assert_called_once_with()
     client.log_exception.assert_not_called()
Example #2
0
 def test_start_stop(self):
     sync_factory = SyncFactory("s")
     process = Mock()
     process.spawn = sync_factory.spawn
     process.create_queue = sync_factory.create_queue
     client = ClientComms("c", process)
     client.send_loop = Mock(side_effect = client.send_loop)
     client.start_recv_loop = Mock()
     client.stop_recv_loop = Mock()
     client.log_exception = Mock()
     client.start()
     self.assertFalse(client._send_spawned.ready())
     client.start_recv_loop.assert_called_once_with()
     client.stop(0.1)
     self.assertTrue(client._send_spawned.ready())
     client.send_loop.assert_called_once_with()
     client.stop_recv_loop.assert_called_once_with()
     client.log_exception.assert_not_called()