mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
- noVNC's own web client (app/ except the bell sounds, vnc.html,
vnc_lite.html, defaults.json, mandatory.json): the console imports
only noVNC's core, and novncd serves no web pages. AUTHORS, LICENSE.txt
and package.json (the version) stay.
- 24 cached icons no {% bs_icon %} asks for; the icon cache test now
also fails on an icon nothing uses.
- Ace's ext-textarea.js, which nothing loads.
- instances/fixtures/initial_data.json, for an app ("create") that no
longer exists; migration 0006 seeds the flavors.
- webvirtcloud/asgi.py: gunicorn runs the WSGI application only.
- instances/templatetags/tags_active.py: a copy of common_tags'
class_active that no template loads.
- .github/linters/.hadolint.yaml, from super-linter, which no workflow
runs anymore.
42 lines
1.9 KiB
Python
42 lines
1.9 KiB
Python
"""Every {% bs_icon %} of the templates is in the committed icon cache
|
|
(webvirtcloud/bootstrap_icons.py), and the cache holds nothing else: a
|
|
missing one is an error page."""
|
|
|
|
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from django.conf import settings
|
|
from django.template import Context, Template
|
|
|
|
from webvirtcloud.bootstrap_icons import ICONS
|
|
|
|
BASE = Path(settings.BASE_DIR)
|
|
CALL = re.compile(r"\{%\s*bs_icon\s+(.*?)\s*%\}")
|
|
NAME = re.compile(r"""^['"]([^'"]+)['"]""")
|
|
KWARG = re.compile(r"""(\w+)=['"]([^'"]*)['"]""")
|
|
|
|
|
|
class IconCacheTestCase(unittest.TestCase):
|
|
def test_the_cache_holds_every_template_icon_and_no_other(self):
|
|
cache = ICONS
|
|
missing, used = [], set()
|
|
templates = [*BASE.glob("templates/**/*.html"), *BASE.glob("*/templates/**/*.html")]
|
|
self.assertGreater(len(templates), 50) # the globs still find the templates
|
|
for template in templates:
|
|
for args in CALL.findall(template.read_text(encoding="utf-8")):
|
|
name = NAME.match(args)
|
|
self.assertIsNotNone(name, f"{template}: icon name is not a literal: {args}")
|
|
kw = dict(KWARG.findall(args))
|
|
# the file name bs_icon reads
|
|
cached = f"{name.group(1)}_{kw.get('size')}_{kw.get('color')}_{kw.get('extra_classes')}.svg".replace(" ", "_")
|
|
used.add(cached)
|
|
if not (cache / cached).exists():
|
|
missing.append(f"{template.relative_to(BASE)}: {cached}")
|
|
self.assertEqual(missing, [])
|
|
self.assertEqual(sorted({path.name for path in cache.glob("*.svg")} - used), [])
|
|
|
|
def test_an_icon_is_its_svg_inline(self):
|
|
html = Template("{% load bootstrap_icons %}{% bs_icon 'pencil' %}").render(Context())
|
|
self.assertEqual(html, (ICONS / "pencil_None_None_None.svg").read_text(encoding="utf-8"))
|
|
self.assertIn("<svg", html)
|