code: def test_truncate_dict():
      d = {"12345": "12345"}
      length = 5
  
      with mock.patch("mlflow.utils._logger.warning") as mock_warning:
          max_length = length - 1
  
          # Truncate keys
          assert _truncate_dict(d, max_key_length=max_length) == {
              "1...": "12345"
          }
          mock_warning.assert_called_once_with(
              "Truncated the key `1...`"
          )
          mock_warning.reset_mock()
  
          # Truncate values
          assert _truncate_dict(d, max_value_length=max_length) == {
              "12345": "1..."
          }
          mock_warning.assert_called_once_with(
              "Truncated the value of the key `12345`. Truncated value: `1...`"
          )
          mock_warning.reset_mock()
  
          # Truncate both keys and values
          assert _truncate_dict(
              d, max_key_length=max_length, max_value_length=max_length
          ) == {"1...": "1..."}
          assert mock_warning.call_count == 2
          (args1, _), (args2, _) = mock_warning.call_args_list
          assert args1[0] == "Truncated the key `1...`"
          assert (
              args2[0]
              == "Truncated the value of the key `1...`. Truncated value: `1...`"
          )
  
      assert _truncate_dict(
          d, max_key_length=length, max_value_length=length
      ) == {"12345": "12345"}
      assert _truncate_dict(
          d, max_key_length=length + 1, max_value_length=length + 1
      ) == {"12345": "12345"}
  
      with pytest.raises(
          ValueError,
          match="Must specify at least either `max_key_length` or `max_value_length`",
      ):
          _truncate_dict(d)
  
file_path: mlflow/tests/utils/test_utils.py
imports: from unittest import mock
  import pytest
  from mlflow.utils import _chunk_dict, _get_fully_qualified_class_name, _truncate_dict, get_unique_resource_id, merge_dicts
label_desc: Use image node_id 3 for calling a global function with example usage: test_truncate_dict() without return types