Init Project Flexly CMS

This commit is contained in:
Alexey Dudin
2026-11-09 15:32:41 +03:00
commit c778db6208
115 changed files with 5098 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
import unittest
from helpers import NOW, SiteTestCase
from site_engine.core.registry import load_site
from site_engine.core.render import Renderer
from site_engine.core.routes import build_route_table
from site_engine.errors import Report
CORE_15 = {
"site_header", "site_footer", "hero", "page_header", "section", "columns", "richtext",
"image", "card_grid", "collection_list", "entry_header", "cta_banner", "form", "faq", "disclaimer",
}
class BuiltinFragmentsTest(SiteTestCase):
def test_builtin_set_is_exactly_the_15_from_adr_006(self):
reg = load_site(self.site)
builtin = {f.id for f in reg.fragments.values() if f.builtin}
self.assertEqual(builtin, CORE_15)
def test_all_templates_compile_in_sandbox(self):
reg = load_site(self.site)
renderer = Renderer(reg, build_route_table(reg, Report()), Report(), now=NOW)
for fid in CORE_15:
renderer.env.get_template(f"fragment/{fid}")
def test_every_builtin_has_style_and_flat_unique_id(self):
reg = load_site(self.site)
self.assertEqual(reg.report.errors, [])
for fid in CORE_15:
self.assertTrue(reg.fragments[fid].style, fid)
def test_nested_slots_render(self):
self.write("pages/layout-test.md", """---
title: Колонки
status: published
regions:
main:
- id: s1
fragment: section
props: {title: Секция}
slots:
content:
- id: c1
fragment: columns
props: {count: 2}
slots:
col_1:
- {id: t1, fragment: richtext, props: {content: Левая колонка}}
col_2:
- {id: t2, fragment: richtext, props: {content: Правая колонка}}
---
""")
from site_engine.build.pipeline import build_site
build_site(self.site, self.out, now=NOW)
html = (self.out / "current" / "layout-test" / "index.html").read_text(encoding="utf-8")
self.assertIn("Левая колонка", html)
self.assertIn("f-columns--2", html)
def test_slot_depth_limit(self):
from site_engine.core.models import parse_block
raw = {"id": "a1", "fragment": "section"}
node = raw
for i in range(2, 7):
child = {"id": f"a{i}", "fragment": "section"}
node["slots"] = {"content": [child]}
node = child
report = Report()
parse_block(raw, "t", report)
self.assertIn("E_BLOCK_DEPTH", report.codes())
if __name__ == "__main__":
unittest.main()