code: def test_api_cache_invalidation_login(root_verify_key, worker):
      guest_client = worker.guest_client
      worker.root_client.settings.allow_guest_signup(enable=True)
      assert guest_client.register(
          name="q",
          email="a@b.org",
          password="aaa",
          password_verify="aaa",
      )
      guest_client = guest_client.login(email="a@b.org", password="aaa")
      user_id = (
          worker.document_store.partitions["User"]
          .all(root_verify_key)
          .value[-1]
          .id
      )
  
      def get_role(verify_key):
          users = (
              worker.get_service("UserService")
              .stash.get_all(root_verify_key)
              .ok()
          )
          user = [u for u in users if u.verify_key == verify_key][0]
          return user.role
  
      assert (
          get_role(guest_client.credentials.verify_key)
          == ServiceRole.DATA_SCIENTIST
      )
  
      dataset = sy.Dataset(
          name="test2",
      )
      with pytest.raises(SyftAttributeError):
          assert guest_client.upload_dataset(dataset)
  
      assert guest_client.api.services.user.update(
          user_id, UserUpdate(user_id=user_id, name="abcdef")
      )
  
      assert worker.root_client.api.services.user.update(
          user_id,
          UserUpdate(user_id=user_id, role=ServiceRole.DATA_OWNER),
      )
  
      assert (
          get_role(guest_client.credentials.verify_key)
          == ServiceRole.DATA_OWNER
      )
  
      guest_client = guest_client.login(email="a@b.org", password="aaa")
  
      assert guest_client.upload_dataset(dataset)
  
file_path: PySyft/packages/syft/tests/syft/api_test.py
imports: from textwrap import dedent
  from typing import Callable
  import numpy
  import pytest
  import syft
  from syft.service.response import SyftAttributeError
  from syft.service.user.user import UserUpdate
  from syft.service.user.user_roles import ServiceRole
label_desc: Use image node_id 2 for calling a global function with example usage: test_api_cache_invalidation_login(root_verify_key, worker) and returns: user