def test_add_document_no_client(): event = Event(event_id='1') document = Document('plaintext', text="“You're no help,” he told the lime. " "This was unfair. It was only a lime; " "there was nothing special about it at all. " "It was doing the best it could.") event.add_document(document) assert event.documents['plaintext'] == document
def test_add_document(mocker): client = mocker.Mock(EventsClient) client.get_local_instance.return_value = client event = Event(event_id='1', client=client) document = Document('plaintext', text="“You're no help,” he told the lime. " "This was unfair. It was only a lime; " "there was nothing special about it at all. " "It was doing the best it could.") event.add_document(document) assert event.documents['plaintext'] == document client.add_document.assert_called_once_with( '1', 'plaintext', "“You're no help,” he told the lime. " "This was unfair. It was only a lime; " "there was nothing special about it at all. " "It was doing the best it could.")