code: def test_create_registered_model_permission(store):
      username1 = random_str()
      password1 = random_str()
      user1 = _user_maker(store, username1, password1)
  
      name1 = random_str()
      user_id1 = user1.id
      permission1 = READ.name
      rmp1 = _rmp_maker(store, name1, username1, permission1)
      assert rmp1.name == name1
      assert rmp1.user_id == user_id1
      assert rmp1.permission == permission1
  
      # error on duplicate
      with pytest.raises(
          MlflowException,
          match=rf"Registered model permission \(name={name1}, username={username1}\) already exists",
      ) as exception_context:
          _rmp_maker(store, name1, username1, permission1)
      assert exception_context.value.error_code == ErrorCode.Name(
          RESOURCE_ALREADY_EXISTS
      )
  
      # slightly different name is ok
      name2 = random_str()
      rmp2 = _rmp_maker(store, name2, username1, permission1)
      assert rmp2.name == name2
      assert rmp2.user_id == user_id1
      assert rmp2.permission == permission1
  
      # all permissions are ok
      for perm in ALL_PERMISSIONS:
          name3 = random_str()
          rmp3 = _rmp_maker(store, name3, username1, perm)
          assert rmp3.name == name3
          assert rmp3.user_id == user_id1
          assert rmp3.permission == perm
  
      # invalid permission will fail
      name4 = random_str()
      with pytest.raises(
          MlflowException, match=r"Invalid permission"
      ) as exception_context:
          _rmp_maker(
              store, name4, username1, "some_invalid_permission_string"
          )
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
imports: import pytest
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, RESOURCE_ALREADY_EXISTS, RESOURCE_DOES_NOT_EXIST, ErrorCode
  from mlflow.server.auth.entities import ExperimentPermission, RegisteredModelPermission, User
  from mlflow.server.auth.permissions import ALL_PERMISSIONS, EDIT, READ
  from mlflow.server.auth.sqlalchemy_store import SqlAlchemyStore
  from tests.helper_functions import random_str
label_desc: Use image node_id 17 for calling a global function with example usage: test_create_registered_model_permission(store) without return types