code: def test_with_events(self, mock_comms: PropertyMock) -> None:
      mock_comm = MagicMock()
      mock_send = MagicMock(return_value="junk")
      mock_comm.send = mock_send
      mock_comms.return_value = mock_comm
  
      d = Document()
  
      handle = binb.CommsHandle("comms", d)
      d.title = "foo"
      binb.push_notebook(document=d, handle=handle)
      assert mock_comms.call_count > 0
      assert (
          mock_send.call_count == 3
      )  # sends header, metadata, then content
      assert json.loads(mock_send.call_args[0][0]) == {
          "events": [{"kind": "TitleChanged", "title": "foo"}],
      }
      assert mock_send.call_args[1] == {}
  
imports: from __future__ import annotations
  import pytest
  import json
  import os
  from typing import Any
  from unittest.mock import MagicMock, PropertyMock, patch
  from bokeh.document.document import Document
  from bokeh.io.notebook import log
  from bokeh.io.state import State
  import bokeh.io.notebook
label_desc: Use image node_id 2 for calling the Test_push_notebook obj's underlying member method code with example usage: obj.test_with_events(mock_comms) without return types