code: def test_log_artifact(
      http_artifact_repo,
      tmp_path,
      artifact_path,
      filename,
      expected_mime_type,
      monkeypatch,
  ):
      file_path = tmp_path.joinpath(filename)
      file_path.write_text("0")
  
      def assert_called_log_artifact(mock_http_request):
          paths = (
              (artifact_path, file_path.name)
              if artifact_path
              else (file_path.name,)
          )
          mock_http_request.assert_called_once_with(
              http_artifact_repo._host_creds,
              posixpath.join("/", *paths),
              "PUT",
              data=FileObjectMatcher(str(file_path), "rb"),
              extra_headers={"Content-Type": expected_mime_type},
          )
  
      with mock.patch(
          "mlflow.store.artifact.http_artifact_repo.http_request",
          return_value=MockResponse({}, 200),
      ) as mock_put:
          http_artifact_repo.log_artifact(file_path, artifact_path)
          assert_called_log_artifact(mock_put)
  
      with mock.patch(
          "mlflow.store.artifact.http_artifact_repo.http_request",
          return_value=MockResponse({}, 400),
      ):
          with pytest.raises(Exception, match="request failed"):
              http_artifact_repo.log_artifact(file_path, artifact_path)
  
      monkeypatch.setenv("MLFLOW_ENABLE_PROXY_MULTIPART_UPLOAD", "true")
      # assert mpu is triggered when file size is larger than minimum file size
      file_path.write_text(
          "0" * MLFLOW_MULTIPART_UPLOAD_MINIMUM_FILE_SIZE.get()
      )
      with mock.patch.object(
          http_artifact_repo, "_try_multipart_upload", return_value=200
      ) as mock_mpu:
          http_artifact_repo.log_artifact(file_path, artifact_path)
          mock_mpu.assert_called_once()
  
      # assert reverted to normal upload when mpu is not supported
      # mock that create_multipart_upload will returns a 400 error with appropriate message
      with mock.patch.object(
          http_artifact_repo,
          "create_multipart_upload",
          side_effect=HTTPError(
              response=MockResponse(
                  data={
                      "message": "Multipart upload is not supported for the current "
                      "artifact repository"
                  },
                  status_code=501,
              )
          ),
      ), mock.patch(
          "mlflow.store.artifact.http_artifact_repo.http_request",
          return_value=MockResponse({}, 200),
      ) as mock_put:
          http_artifact_repo.log_artifact(file_path, artifact_path)
          assert_called_log_artifact(mock_put)
  
      # assert if mpu is triggered but the uploads failed, mpu is aborted and exception is raised
      with mock.patch(
          "requests.put", side_effect=Exception("MPU_UPLOAD_FAILS")
      ), mock.patch.object(
          http_artifact_repo,
          "create_multipart_upload",
          return_value=CreateMultipartUploadResponse(
              upload_id="upload_id",
              credentials=[
                  MultipartUploadCredential(
                      url="url", part_number=1, headers={}
                  )
              ],
          ),
      ), mock.patch.object(
          http_artifact_repo,
          "abort_multipart_upload",
          return_value=None,
      ) as mock_abort:
          with pytest.raises(Exception, match="MPU_UPLOAD_FAILS"):
              http_artifact_repo.log_artifact(file_path, artifact_path)
          mock_abort.assert_called_once()
  
imports: import os
  import posixpath
  from unittest import mock
  import pytest
  from requests import HTTPError
  from mlflow.entities.multipart_upload import CreateMultipartUploadResponse, MultipartUploadCredential, MultipartUploadPart
  from mlflow.environment_variables import MLFLOW_MULTIPART_UPLOAD_MINIMUM_FILE_SIZE, MLFLOW_TRACKING_CLIENT_CERT_PATH, MLFLOW_TRACKING_INSECURE_TLS, MLFLOW_TRACKING_PASSWORD, MLFLOW_TRACKING_SERVER_CERT_PATH, MLFLOW_TRACKING_TOKEN, MLFLOW_TRACKING_USERNAME
  from mlflow.exceptions import MlflowException
  from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
  from mlflow.store.artifact.http_artifact_repo import HttpArtifactRepository
  from mlflow.tracking._tracking_service.utils import _get_default_host_creds
  from mlflow.utils.rest_utils import MlflowHostCreds
label_desc: Use image node_id 3 for calling a global function with example usage: test_log_artifact(http_artifact_repo, tmp_path, artifact_path, filename, expected_mime_type, monkeypatch) without return types