code: def test_group_deleted_if_error_when_adding_model(
      self, conn_mock, create_group_mock, group_created
  ):
      group = "group-name"
      op = SageMakerRegisterModelVersionOperator(
          task_id="test",
          image_uri="257758044811.dkr.ecr.us-east-2.amazonaws.com/sagemaker-xgboost:1.2-1",
          model_url="s3://your-bucket-name/model.tar.gz",
          package_group_name=group,
          model_approval=ApprovalStatus.APPROVED,
      )
      create_group_mock.return_value = group_created
      conn_mock().create_model_package.side_effect = ClientError(
          error_response={"Error": {"Code": "ohno"}},
          operation_name="empty",
      )
  
      with pytest.raises(ClientError):
          op.execute(None)
  
      if group_created:
          # delete group if it was created and there was an error in the second step (create model package)
          conn_mock().delete_model_package_group.assert_called_once_with(
              ModelPackageGroupName=group
          )
      else:
          # if the group already existed, we don't want to delete it in case of error on second step
          conn_mock().delete_model_package_group.assert_not_called()
  
file_path: airflow/tests/providers/amazon/aws/operators/test_sagemaker_model.py
imports: from __future__ import annotations
  from unittest import mock
  from unittest.mock import patch
  import pytest
  from botocore.exceptions import ClientError
  from airflow.exceptions import AirflowException
  from airflow.providers.amazon.aws.hooks.sagemaker import SageMakerHook
  from airflow.providers.amazon.aws.operators.sagemaker import ApprovalStatus, SageMakerDeleteModelOperator, SageMakerModelOperator, SageMakerRegisterModelVersionOperator
label_desc: Use image node_id 2 for calling the TestSageMakerRegisterModelVersionOperator obj's underlying member method code with example usage: obj.test_group_deleted_if_error_when_adding_model(conn_mock, create_group_mock, group_created) without return types