code: def test_dynamic_route():
      config = GatewayConfig(
          **{
              "routes": [
                  {
                      "name": "chat",
                      "route_type": "llm/v1/chat",
                      "model": {
                          "name": "gpt-4",
                          "provider": "openai",
                          "config": {
                              "openai_api_key": "mykey",
                              "openai_api_base": "https://api.openai.com/v1",
                          },
                      },
                  }
              ]
          }
      )
      app = create_app_from_config(config)
      client = TestClient(app)
  
      resp = {
          "id": "chatcmpl-abc123",
          "object": "chat.completion",
          "created": 1677858242,
          "model": "gpt-3.5-turbo-0301",
          "usage": {
              "prompt_tokens": 13,
              "completion_tokens": 7,
              "total_tokens": 20,
          },
          "choices": [
              {
                  "message": {
                      "role": "assistant",
                      "content": "\n\nThis is a test!",
                  },
                  "finish_reason": "stop",
                  "index": 0,
              }
          ],
          "headers": {"Content-Type": "application/json"},
      }
      with mock.patch(
          "aiohttp.ClientSession.post",
          return_value=MockAsyncResponse(resp),
      ) as mock_post:
          resp = client.post(
              f"{MLFLOW_GATEWAY_ROUTE_BASE}chat/invocations",
              json={
                  "messages": [
                      {"role": "user", "content": "Tell me a joke"}
                  ]
              },
          )
          mock_post.assert_called_once()
          assert resp.status_code == 200
          assert resp.json() == {
              "id": "chatcmpl-abc123",
              "object": "chat.completion",
              "created": 1677858242,
              "model": "gpt-3.5-turbo-0301",
              "usage": {
                  "prompt_tokens": 13,
                  "completion_tokens": 7,
                  "total_tokens": 20,
              },
              "choices": [
                  {
                      "message": {
                          "role": "assistant",
                          "content": "\n\nThis is a test!",
                      },
                      "finish_reason": "stop",
                      "index": 0,
                  }
              ],
          }
  
file_path: mlflow/tests/gateway/test_gateway_app.py
imports: from unittest import mock
  import pytest
  from fastapi.testclient import TestClient
  from mlflow.exceptions import MlflowException
  from mlflow.gateway.app import create_app_from_config, create_app_from_env
  from mlflow.gateway.config import GatewayConfig
  from mlflow.gateway.constants import MLFLOW_GATEWAY_CRUD_ROUTE_BASE, MLFLOW_GATEWAY_ROUTE_BASE
  from tests.gateway.tools import MockAsyncResponse
label_desc: Use image node_id 8 for calling a global function with example usage: test_dynamic_route() without return types