Skip to content

Commit

Permalink
Merge pull request #433 from render-engine:fix-theme-loading
Browse files Browse the repository at this point in the history
Fix register theme and add test
  • Loading branch information
kjaymiller committed Dec 2, 2023
2 parents 1b3cde2 + cc31049 commit 69e277e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/render_engine/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def register_theme(self, theme: Theme):
self.theme_manager.register_theme(theme)

if theme.plugins:
self.plugin_manager._pm.register_plugins(*theme.plugins)
self.register_plugins(*theme.plugins)

def register_themes(self, *themes: Theme):
"""
Expand Down
22 changes: 21 additions & 1 deletion tests/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import pluggy
import pytest
from jinja2 import FileSystemLoader
from jinja2 import FileSystemLoader, DictLoader

from render_engine.collection import Collection
from render_engine.page import Page
from render_engine.site import Site
from render_engine.themes import Theme
from render_engine.hookspecs import SiteSpecs

pm = pluggy.PluginManager("fake_test")

Expand Down Expand Up @@ -295,3 +297,21 @@ def test_site_theme_update_settings():
assert "test" not in site.site_vars
site.update_theme_settings(test="test")
assert site.site_vars["theme"]["test"] == "test"


def test_plugin_in_theme_added_to_plugins():
"""Tests that a plugin added to a theme is added to the site"""
class plugin(SiteSpecs):
pass

class theme(Theme):
loader = DictLoader({"test.html": "test"})
plugins = [plugin]
filters = []


site = Site()
site.register_theme(
theme,
)
assert plugin in site.plugin_manager.plugins

0 comments on commit 69e277e

Please sign in to comment.