code: def test_loading_existing_state(mock_file, makedirs):
      # given
      resolved_path = MagicMock(spec=Path, exists=lambda: True)
      file_path = MagicMock(
          spec=Path, resolve=lambda strict: resolved_path
      )
      data_path = MagicMock(
          spec=Path, __truediv__=lambda self, key: file_path
      )
  
      # when
      with MetadataFile(data_path=data_path) as metadata:
          # then
          mock_file.assert_called_with(resolved_path, "r")
          makedirs.assert_called_with(data_path, exist_ok=True)
  
          # and
          assert metadata["version"] == 5
          assert metadata["dependencies"] == ["a==1.0", "b==2.0"]
  
imports: from pathlib import Path
  from mock import MagicMock, mock_open, patch
  from neptune.internal.metadata_file import MetadataFile
label_desc: Use image node_id 2 for calling a global function with example usage: test_loading_existing_state(mock_file, makedirs) without return types