code: def test_generate_api_key(
      relay_server, inject_users, inject_graphql_response
  ):
      email = "test@test.com"
      api_keys = [
          {"name": "Y" * 40, "id": "QXBpS2V5OjE4MzA="},
          {"name": "X" * 40, "id": "QXBpS2V5OjE4MzE="},
      ]
      inject_response = [inject_users(email, [api_keys[0]], [])]
      inject_generate_api_key_success = inject_graphql_response(
          body=json.dumps(
              {"data": {"generateApiKey": {"apiKey": api_keys[1]}}}
          ),
          query_match_fn=lambda query, variables: "mutation GenerateApiKey("
          in query
          and variables["description"] == "good",
          application_pattern="1",
      )
      inject_response.append(inject_generate_api_key_success)
      inject_generate_api_key_conflict = inject_graphql_response(
          body=json.dumps({"error": "resource already exists"}),
          status=409,
          query_match_fn=lambda query, variables: "mutation GenerateApiKey("
          in query
          and variables["description"] == "conflict",
          application_pattern="1",
      )
      inject_response.append(inject_generate_api_key_conflict)
  
      with relay_server(inject=inject_response):
          user = Api().user(email)
          key = user.api_keys[0]
          new_key = user.generate_api_key("good")
          assert (
              user.api_keys[-1] != key and user.api_keys[-1] == new_key
          )
          assert user.generate_api_key("conflict") is None
  
imports: import json
  from typing import Dict, List, Optional
  from unittest import mock
  import pytest
  import requests
  import wandb
  import wandb.apis.public
  import wandb.util
  from wandb import Api
  from wandb.old.summary import Summary
  from wandb.sdk.lib import runid
label_desc: Use image node_id 37 for calling a global function with example usage: test_generate_api_key(relay_server, inject_users, inject_graphql_response) without return types