code: def validate_response_expectations(expectations: Dict[str, Any]):
      if not expectations["content_type"] in CONTENT_TO_ATTR.keys():
          raise ExpectationsValidationException(
              f"response.content_type should be one of {CONTENT_TO_ATTR.keys()}"
          )
  
      if "expected" in expectations and "json_schema" in expectations:
          raise ExpectationsValidationException(
              "expected and json_schema are mutually exclusive"
          )
  
      if "json_schema" in expectations:
          if expectations["content_type"] != "json":
              raise ExpectationsValidationException(
                  "json_schema is only valid when content_type is set to json"
              )
  
          try:
              Draft7Validator.check_schema(
                  schema=expectations["json_schema"]
              )
          except Exception as e:
              raise ExpectationsValidationException(
                  "json_schema is invalid"
              ) from e
  
      if "grpc" in expectations:
          grpc = expectations["grpc"]
          required_fields = [
              "proto_module_pb2",
              "proto_module_pb2_grpc",
              "stub_service_name",
              "input_spec",
              "output_spec",
          ]
          for required_field in required_fields:
              if required_field not in grpc:
                  raise ExpectationsValidationException(
                      f"missing grpc.{required_field} field"
                  )
  
          p1 = str(pathlib.Path(grpc["proto_module_pb2"]).parent)
          p2 = str(pathlib.Path(grpc["proto_module_pb2_grpc"]).parent)
          if p1 != p2:
              raise ExpectationsValidationException(
                  "the parent directories of proto_module_pb2 and proto_module_pb2_grpc don't match"
              )
  
          input_spec = grpc["input_spec"]
          if "class_name" not in input_spec:
              raise ExpectationsValidationException(
                  "missing grpc.input_spec.class_name field"
              )
          if "input" not in input_spec:
              raise ExpectationsValidationException(
                  "missing grpc.input_spec.input field"
              )
  
          output_spec = grpc["output_spec"]
          if "class_name" not in output_spec:
              raise ExpectationsValidationException(
                  "missing grpc.output_spec.class_name field"
              )
          if "stream" not in output_spec:
              raise ExpectationsValidationException(
                  "missing grpc.output_spec.stream field"
              )
  
file_path: cortex/test/e2e/e2e/expectations.py
imports: import pathlib
  import types
  from typing import Dict, Any
  import jsonschema
  import requests
  import yaml
  from jsonschema import Draft7Validator
  from e2e.exceptions import ExpectationsValidationException
label_desc: Use image node_id 5 for calling a global function with example usage: validate_response_expectations(expectations) without return types