def test_destroy_closes_file_handle(self):
        file_handle = self._mock_open.return_value = MagicMock()
        file_handle.close = MagicMock()

        sut = EveChatLogReader("path")
        sut.destroy()

        file_handle.close.assert_called_once()
    def test_read_message_cleans_trailing_white_space(self):
        file_handle = self._mock_open.return_value = MagicMock()
        file_handle.read = MagicMock()
        file_handle.read.return_value = MESSAGE_WITH_TRAILING_WHITE

        sut = EveChatLogReader("path")
        messages = sut.read_messages()

        self.assertEqual("[ 2015.03.05 21:04:03 ] Some Dude > MSG\nON NEXT LINE\nANOTHER LINE", messages[0])
    def test_read_message_cleans_boms(self):
        file_handle = self._mock_open.return_value = MagicMock()
        file_handle.read = MagicMock()
        file_handle.read.return_value = MESSAGE_WITH_BOMS

        sut = EveChatLogReader("path")
        messages = sut.read_messages()

        self.assertFalse(EveChatLogReader.chat_line_delimiter in messages[0])
    def test_read_message_splits_single_message(self):
        file_handle = self._mock_open.return_value = MagicMock()
        file_handle.read = MagicMock()
        file_handle.read.return_value = READ_SINGLE_MESSAGES

        sut = EveChatLogReader("path")
        messages = sut.read_messages()

        self.assertEqual(1, len(messages))
        self.assertEqual(MESSAGE_SINGLE_LINE, messages[0])
    def test_read_message_reads_to_end(self):
        file_handle = self._mock_open.return_value = MagicMock()
        file_handle.read = MagicMock()

        calls = []

        for i in range(file_handle.read.call_count + 1):
            calls.append(call(None))

        sut = EveChatLogReader("path")
        sut.read_messages()

        file_handle.read.assert_has_calls(calls)