code: def test_user_register_for_role(
      monkeypatch: MonkeyPatch, faker: Faker
  ):
      # Mock patch this env variable to remove race conditions
      # where signup is enabled.
      def get_mock_client(faker, root_client, role):
          user_create = UserCreate(
              name=faker.name(),
              email=faker.email(),
              role=role,
              password="password",
              password_verify="password",
          )
          result = root_client.users.create(user_create=user_create)
          assert not isinstance(result, SyftError)
  
          guest_client = root_client.guest()
          return guest_client.login(
              email=user_create.email, password=user_create.password
          )
  
      verify_key = SyftSigningKey.generate().verify_key
      mock_node_settings = NodeSettingsV2(
          name=faker.name(),
          verify_key=verify_key,
          highest_version=1,
          lowest_version=2,
          syft_version=syft.__version__,
          signup_enabled=False,
          admin_email="info@openmined.org",
          node_side_type=NodeSideType.LOW_SIDE,
          show_warnings=False,
          deployed_on=datetime.now().date().strftime("%m/%d/%Y"),
      )
  
      with mock.patch(
          "syft.Worker.settings",
          new_callable=mock.PropertyMock,
          return_value=mock_node_settings,
      ):
          worker = syft.Worker.named(name=faker.name(), reset=True)
          root_client = worker.root_client
  
          emails_added = []
          for role in [ServiceRole.DATA_OWNER, ServiceRole.ADMIN]:
              client = get_mock_client(
                  faker=faker, root_client=root_client, role=role
              )
              email = faker.email()
              result = client.register(
                  name=faker.name(),
                  email=email,
                  password="password",
                  password_verify="password",
              )
              assert isinstance(result, SyftSuccess)
              emails_added.append(email)
  
          ds_client = get_mock_client(
              faker=faker,
              root_client=root_client,
              role=ServiceRole.DATA_SCIENTIST,
          )
  
          response = ds_client.register(
              name=faker.name(),
              email=faker.email(),
              password="password",
              password_verify="password",
          )
          assert isinstance(response, SyftError)
  
          users_created_count = sum(
              [
                  u.email in emails_added
                  for u in root_client.users.get_all()
              ]
          )
          assert users_created_count == len(emails_added)
  
imports: from copy import deepcopy
  from datetime import datetime
  from unittest import mock
  from faker import Faker
  from pytest import MonkeyPatch
  from result import Err
  from result import Ok
  import syft
  from syft.abstract_node import NodeSideType
  from syft.node.credentials import SyftSigningKey
  from syft.node.credentials import SyftVerifyKey
  from syft.service.context import AuthedServiceContext
  from syft.service.response import SyftError
  from syft.service.response import SyftSuccess
  from syft.service.settings.settings import NodeSettingsUpdate
  from syft.service.settings.settings import NodeSettingsV2
  from syft.service.settings.settings_service import SettingsService
  from syft.service.settings.settings_stash import SettingsStash
  from syft.service.user.user import UserCreate
  from syft.service.user.user_roles import ServiceRole
label_desc: Use image node_id 11 for calling a global function with example usage: test_user_register_for_role(monkeypatch, faker) and returns: guest_client