code: def test_create_env_with_mamba(monkeypatch):
      """
      Test that mamba is called when set, and that we fail when mamba is not available or is
      not working. We mock the calls so we do not actually execute mamba (which is not
      installed in the test environment anyway)
      """
  
      def exec_cmd_mock(
          cmd, *args, **kwargs
      ):  # pylint: disable=unused-argument
          if cmd[-1] == "--json":
              # We are supposed to list environments in JSON format
              return subprocess.CompletedProcess(
                  cmd,
                  0,
                  json.dumps({"envs": ["mlflow-mock-environment"]}),
                  None,
              )
          else:
              # Here we are creating the environment, no need to return
              # anything
              return subprocess.CompletedProcess(cmd, 0)
  
      def exec_cmd_mock_raise(
          cmd, *args, **kwargs
      ):  # pylint: disable=unused-argument
          if os.path.basename(cmd[0]) == "mamba":
              raise OSError()
  
      conda_env_path = os.path.join(TEST_PROJECT_DIR, "conda.yaml")
  
      monkeypatch.setenv(MLFLOW_CONDA_CREATE_ENV_CMD.name, "mamba")
      # Simulate success
      with mock.patch(
          "mlflow.utils.process._exec_cmd", side_effect=exec_cmd_mock
      ):
          mlflow.utils.conda.get_or_create_conda_env(conda_env_path)
  
      # Simulate a non-working or non-existent mamba
      with mock.patch(
          "mlflow.utils.process._exec_cmd",
          side_effect=exec_cmd_mock_raise,
      ):
          with pytest.raises(
              ExecutionException,
              match="You have set the env variable MLFLOW_CONDA_CREATE_ENV_CMD",
          ):
              mlflow.utils.conda.get_or_create_conda_env(conda_env_path)
  
imports: import json
  import os
  import shutil
  import subprocess
  import uuid
  from unittest import mock
  import git
  import pytest
  import yaml
  from databricks_cli.configure.provider import DatabricksConfig
  import mlflow
  from mlflow import MlflowClient
  from mlflow.entities import RunStatus, SourceType, ViewType
  from mlflow.environment_variables import MLFLOW_CONDA_CREATE_ENV_CMD, MLFLOW_CONDA_HOME
  from mlflow.exceptions import ExecutionException, MlflowException
  from mlflow.projects import _parse_kubernetes_config, _resolve_experiment_id
  from mlflow.store.tracking.file_store import FileStore
  from mlflow.utils import PYTHON_VERSION
  from mlflow.utils.conda import CONDA_EXE, get_or_create_conda_env
  from mlflow.utils.mlflow_tags import LEGACY_MLFLOW_GIT_BRANCH_NAME, LEGACY_MLFLOW_GIT_REPO_URL, MLFLOW_GIT_BRANCH, MLFLOW_GIT_REPO_URL, MLFLOW_PARENT_RUN_ID, MLFLOW_PROJECT_BACKEND, MLFLOW_PROJECT_ENTRY_POINT, MLFLOW_PROJECT_ENV, MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE, MLFLOW_USER
  from mlflow.utils.process import ShellCommandException
  from tests.projects.utils import TEST_PROJECT_DIR, TEST_PROJECT_NAME, validate_exit_status
label_desc: Use image node_id 16 for calling a global function with example usage: test_create_env_with_mamba(monkeypatch) and returns: subprocess, subprocess