When you start the development of a new feature, the first test you might want to write is the primary acceptance test – the one that helps you define "this is what I want to achieve." Acceptance tests expose the components we need to create and the behaviors they need to have, allowing us to move forward by designing the development tests for those components and thus writing down unit and integration tests.
In the case of the chat application, our acceptance test will probably be a test where one user can send a message and another user can receive it:
import unittest
class TestChatAcceptance(unittest.TestCase):
def test_message_exchange(self):
user1 = ChatClient("John Doe")
user2 = ChatClient("Harry Potter")
user1.send_message("Hello World")
messages = user2.fetch_messages()
assert messages == ["John Doe: Hello World"]
if __name__...