# retoor <retoor@molodetz.nl>

import html
import json
import re
import requests
from tests.conftest import BASE_URL
from devplacepy.database import get_table
from devplacepy.docs_api import API_GROUPS
from devplacepy.utils import clear_user_cache
def _configs_by_id(text):
    configs = re.findall(r"data-config='(.*?)'", text, re.S)
    return {
        json.loads(html.unescape(cfg))["id"]: json.loads(html.unescape(cfg))
        for cfg in configs
    }


def test_docs_download_html_is_self_contained(app_server):
    r = requests.get(f"{BASE_URL}/docs/download.html")
    assert r.status_code == 200
    assert 'filename="devplace-docs.html"' in r.headers["content-disposition"]
    assert "application/x-markdown-base64" in r.text
    assert "marked" in r.text and "hljs" in r.text  # libraries inlined
