We know that ChatClient must use a connection to send and receive the messages. So the next thing we have to do to make sure our test_message_exchange test passes is to make sure that the connection exists and is used. But we don't want to establish a connection every time a ChatClient is created, so the idea is to create a connection through a method that lazily makes them when they're needed the first time.
We will call this method ChatClient._get_connection and we want to make sure that ChatClient will actually use the connection provided by that method. To verify that ChatClient uses the provided connection, we are going to set up a test with a spy, a kind of dummy object that, instead of doing nothing, actually records how it was called (if it was) and with which arguments.
As we did when setting up the stub, we are going to use unittest.mock.patch to replace the ChatClient._get_connection method with a stub that, instead of returning the...