mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
131 test modules sat next to the code they test; instances alone had 51 of them beside views.py and utils.py. They move into a tests/ package per app, and the JavaScript checks into webvirtcloud/tests/js. Each non-empty tests.py becomes tests/test_views.py; the empty generated stubs are removed. Imports of the app's own modules become absolute, paths built from __file__ go one level up, the live helper is instances.tests.livetest, and coverage omits */tests/*. The suite discovers the same 960 tests as before.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""The themes in dev/scss/wvc-themes compile with the pinned libsass, and the
|
|
shipped wvc-main.min.css is the default theme compiled from these sources."""
|
|
|
|
from pathlib import Path
|
|
|
|
import sass
|
|
from django.conf import settings
|
|
from django.test import SimpleTestCase
|
|
|
|
SCSS = Path(settings.BASE_DIR, "dev", "scss")
|
|
|
|
|
|
def compile_theme(theme):
|
|
# the imports the settings view compiles
|
|
return sass.compile(
|
|
string=f"@import '{SCSS}/wvc-themes/{theme}/variables';\n"
|
|
f"@import '{SCSS}/bootstrap-overrides.scss';\n"
|
|
f"@import '{SCSS}/wvc-themes/{theme}/bootswatch';",
|
|
output_style="compressed",
|
|
)
|
|
|
|
|
|
class ThemeTests(SimpleTestCase):
|
|
def test_every_theme_compiles(self):
|
|
themes = sorted(p.name for p in (SCSS / "wvc-themes").iterdir() if p.is_dir())
|
|
self.assertIn("zephyr", themes)
|
|
for theme in themes:
|
|
with self.subTest(theme=theme):
|
|
self.assertIn(".btn", compile_theme(theme))
|
|
|
|
def test_the_shipped_css_is_zephyr_from_these_sources(self):
|
|
shipped = Path(settings.BASE_DIR, "static", "css", "wvc-main.min.css").read_text()
|
|
self.assertEqual(shipped, compile_theme("zephyr"))
|