code: def test_add_and_remove_model_groups_limit(sagemaker_session):
      collection = Collection(sagemaker_session)
      model_groups = []
      for i in range(11):
          model_groups.append(f"test-model-group{i}")
      try:
          collection.add_model_groups(
              collection_name=[COLLECTION_NAME],
              model_groups=model_groups,
          )
      except Exception as e:
          assert "Model groups can have a maximum length of 10" in str(
              e
          )
  
      try:
          collection.remove_model_groups(
              collection_name=[COLLECTION_NAME],
              model_groups=model_groups,
          )
      except Exception as e:
          assert "Model groups can have a maximum length of 10" in str(
              e
          )
  
file_path: sagemaker-python-sdk/tests/unit/test_collection.py
imports: from __future__ import absolute_import
  import pytest
  import json
  from mock import Mock
  from sagemaker.collection import Collection
label_desc: Use image node_id 7 for calling a global function with example usage: test_add_and_remove_model_groups_limit(sagemaker_session) without return types