# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os
import subprocess

from django.conf import settings
from django.test import TestCase, override_settings
from typing import Any, Dict, List

from zproject.settings import DEPLOY_ROOT
from zerver.lib.integrations import INTEGRATIONS, HUBOT_LOZENGES
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import HostRequestMock
from zerver.lib.utils import split_by
from zerver.views.integrations import (
    add_api_uri_context,
    add_integrations_context,
)

class DocPageTest(ZulipTestCase):
    def _test(self, url, expected_content, extra_strings=[]):
        # type: (str, str, List[str]) -> None
        result = self.client_get(url)
        self.assertEqual(result.status_code, 200)
        self.assertIn(expected_content, str(result.content))
        for s in extra_strings:
            self.assertIn(s, str(result.content))

    def test_doc_endpoints(self):
        # type: () -> None
        self._test('/api/', 'We hear you like APIs')
        self._test('/api/endpoints/', 'pre-built API bindings for')
        self._test('/about/', 'Cambridge, Massachusetts')
        # Test the i18n version of one of these pages.
        self._test('/en/about/', 'Cambridge, Massachusetts')
        self._test('/apps/', 'Apps for every platform.')
        self._test('/features/', 'Beautiful messaging')
        self._test('/hello/', 'productive group chat')
        self._test('/why-zulip/', 'all stakeholders can see and')
        self._test('/for/open-source/', 'for open source projects')
        self._test('/for/companies/', 'in a company')
        self._test('/for/working-groups-and-communities/', 'standards bodies')
        self._test('/integrations/',
                   'Over 60 native integrations.',