code: def test_hangouts_extract_functions():
      # from https://developers.google.com/hangouts/chat/reference/message-formats/events#added_to_space # noqa: E501
      ADDED_EVENT = {
          "type": "ADDED_TO_SPACE",
          "eventTime": "2017-03-02T19:02:59.910959Z",
          "space": {
              "name": "spaces/AAAAAAAAAAA",
              "displayName": "Chuck Norris Discussion Room",
              "type": "ROOM",
          },
          "user": {
              "name": "users/12345678901234567890",
              "displayName": "Chuck Norris",
              "avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
              "email": "chuck@example.com",
          },
      }
  
      # from https://developers.google.com/hangouts/chat/reference/message-formats/events#removed_from_space # noqa: E501
      REMOVED_EVENT = {
          "type": "REMOVED_FROM_SPACE",
          "eventTime": "2017-03-02T19:02:59.910959Z",
          "space": {"name": "spaces/AAAAAAAAAAA", "type": "DM"},
          "user": {
              "name": "users/12345678901234567890",
              "displayName": "Chuck Norris",
              "avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
              "email": "chuck@example.com",
          },
      }
  
      # from https://developers.google.com/hangouts/chat/reference/message-formats/events#message # noqa: E501
      MESSAGE = {
          "type": "MESSAGE",
          "eventTime": "2017-03-02T19:02:59.910959Z",
          "space": {
              "name": "spaces/AAAAAAAAAAA",
              "displayName": "Chuck Norris Discussion Room",
              "type": "ROOM",
          },
          "message": {
              "name": "spaces/AAAAAAAAAAA/messages/CCCCCCCCCCC",
              "sender": {
                  "name": "users/12345678901234567890",
                  "displayName": "Chuck Norris",
                  "avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
                  "email": "chuck@example.com",
              },
              "createTime": "2017-03-02T19:02:59.910959Z",
              "text": "@TestBot Violence is my last option.",
              "argumentText": " Violence is my last option.",
              "thread": {
                  "name": "spaces/AAAAAAAAAAA/threads/BBBBBBBBBBB"
              },
              "annotations": [
                  {
                      "length": 8,
                      "startIndex": 0,
                      "userMention": {
                          "type": "MENTION",
                          "user": {
                              "avatarUrl": "https://.../avatar.png",
                              "displayName": "TestBot",
                              "name": "users/1234567890987654321",
                              "type": "BOT",
                          },
                      },
                      "type": "USER_MENTION",
                  }
              ],
          },
          "user": {
              "name": "users/12345678901234567890",
              "displayName": "Chuck Norris",
              "avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
              "email": "chuck@example.com",
          },
      }
  
      from rasa.core.channels.hangouts import HangoutsInput
      import rasa.core
  
      input_channel = HangoutsInput(
          project_id="12345678901",
          # intent name for bot added to direct message event
          hangouts_user_added_intent_name="/added_dm",
          # intent name for bot added to room event
          hangouts_room_added_intent_name="/added_room",
          # intent name for bot removed from space event
          hangouts_removed_intent_name="/removed",
      )
  
      app = rasa.core.run.configure_app([input_channel], port=5004)
  
      # This causes irritating error even though test passes...
      # req, _ = app.test_client.post("/webhooks/hangouts/webhook",
      #                                   data=json.dumps(MESSAGE))
      # ..therefore create Request object directly
      from sanic.request import Request
  
      def create_req(app):
          return Request(
              b"http://127.0.0.1:42101/webhooks/hangouts/webhook",
              [],
              None,
              "POST",
              None,
              app=app,
          )
  
      req = create_req(app)
      req.body = bytes(json.dumps(MESSAGE), encoding="utf-8")
      assert input_channel._extract_sender(req) == "Chuck Norris"
      assert (
          input_channel._extract_room(req)
          == "Chuck Norris Discussion Room"
      )
      assert (
          input_channel._extract_message(req)
          == "@TestBot Violence is my last option."
      )
  
      req = create_req(app)
      req.body = bytes(json.dumps(ADDED_EVENT), encoding="utf-8")
      assert input_channel._extract_sender(req) == "Chuck Norris"
      assert (
          input_channel._extract_room(req)
          == "Chuck Norris Discussion Room"
      )
      assert input_channel._extract_message(req) == "/added_room"
  
      req = create_req(app)
      req.body = bytes(json.dumps(REMOVED_EVENT), encoding="utf-8")
      assert input_channel._extract_sender(req) == "Chuck Norris"
      assert input_channel._extract_room(req) is None
      assert input_channel._extract_message(req) == "/removed"
  
imports: import json
  import logging
  import pytest
  from rasa.core import utils
label_desc: Use image node_id 2 for calling a global function with example usage: test_hangouts_extract_functions() and returns: Request