code: def test_write_json(capsys, mocker, isatty, expected_output):
      """Test that ui.write_json works."""
  
      console = Console(enable=True)
      mocker.patch.object(console, "isatty", return_value=isatty)
      message = {
          "hello": "world",
          "date": datetime.datetime(1970, 1, 1),
      }
      console.write_json(message, default=str)
      captured = capsys.readouterr()
      assert captured.out == expected_output
  
imports: import datetime
  import textwrap
  import pytest
  from dvc.ui import Console
label_desc: Use image node_id 2 for calling a global function with example usage: test_write_json(capsys, mocker, isatty, expected_output) without return types