import os
from typing import Any, Dict, Sequence
from unittest import mock
from urllib.parse import urlsplit

import ujson
from django.conf import settings
from django.http import HttpResponse
from django.test import override_settings

from corporate.models import Customer
from zerver.lib.integrations import INTEGRATIONS
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import HostRequestMock
from zerver.lib.utils import split_by
from zerver.models import Realm, get_realm
from zerver.views.documentation import add_api_uri_context


class DocPageTest(ZulipTestCase):
    def get_doc(self, url: str, subdomain: str) -> HttpResponse:
        if url[0:23] == "/integrations/doc-html/":
            return self.client_get(url, subdomain=subdomain, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        return self.client_get(url, subdomain=subdomain)

    def print_msg_if_error(self, url: str, response: HttpResponse) -> None:  # nocoverage
        if response.status_code == 200:
            return
        print("Error processing URL:", url)