code: def test_model_and_endpoint_config_exist(
      name_from_image_mock, sagemaker_session
  ):
      container_def_with_env = CONTAINER_DEF.copy()
  
      sagemaker_session.create_endpoint_config = Mock(
          name="create_endpoint_config",
          side_effect=_raise_does_already_exists_client_error,
      )
  
      try:
          sagemaker_session.endpoint_from_model_data(
              model_s3_location=S3_MODEL_ARTIFACTS,
              image_uri=DEPLOY_IMAGE,
              initial_instance_count=INITIAL_INSTANCE_COUNT,
              instance_type=INSTANCE_TYPE,
              wait=False,
          )
      except ClientError:
          assert (
              False
          ), "Unexpected ClientError raised for resource already exists scenario"
  
      sagemaker_session.create_model.assert_called_once_with(
          name=NAME_FROM_IMAGE,
          role=None,
          container_defs=container_def_with_env,
          vpc_config=None,
      )
      sagemaker_session.create_endpoint_config.assert_called_once_with(
          name=NAME_FROM_IMAGE,
          model_name=NAME_FROM_IMAGE,
          initial_instance_count=INITIAL_INSTANCE_COUNT,
          instance_type=INSTANCE_TYPE,
          accelerator_type=None,
          data_capture_config_dict=None,
          tags=None,
      )
      sagemaker_session.create_endpoint.assert_called_once_with(
          endpoint_name=NAME_FROM_IMAGE,
          config_name=NAME_FROM_IMAGE,
          wait=False,
          tags=None,
      )
  
file_path: sagemaker-python-sdk/tests/unit/test_endpoint_from_model_data.py
imports: from __future__ import absolute_import
  import pytest
  from botocore.exceptions import ClientError
  from mock import MagicMock, Mock
  from mock import patch
  from .common import _raise_unexpected_client_error, _raise_does_already_exists_client_error, _raise_does_not_exist_client_error
  import sagemaker
label_desc: Use image node_id 4 for calling a global function with example usage: test_model_and_endpoint_config_exist(name_from_image_mock, sagemaker_session) without return types