3
0
Fork 0

feat: add MasterView registry/discovery mechanism

and show related MasterView link buttons when viewing App Table

also show some more info about model class when viewing table
This commit is contained in:
Lance Edgar 2025-12-29 17:51:39 -06:00
parent 0619f070c7
commit 484e1f810a
8 changed files with 225 additions and 16 deletions

61
tests/test_conf.py Normal file
View file

@ -0,0 +1,61 @@
# -*- coding: utf-8; -*-
from wuttjamaican.db.model import User
from wuttjamaican.testing import ConfigTestCase
from wuttaweb import conf as mod
from wuttaweb.testing import WebTestCase
from wuttaweb.views import MasterView
class TestWuttaWebConfigExtension(ConfigTestCase):
def test_basic(self):
# continuum plugin not set yet (b/c config was not extended)
self.assertIsNone(self.config.get("wutta_continuum.wutta_plugin_spec"))
# so let's extend it
extension = mod.WuttaWebConfigExtension()
extension.configure(self.config)
self.assertEqual(
self.config.get("wutta_continuum.wutta_plugin_spec"),
"wuttaweb.db.continuum:WuttaWebContinuumPlugin",
)
class MasterWithClass(MasterView):
model_class = User
class MasterWithName(MasterView):
model_class = "Widget"
class TestAddMasterView(WebTestCase):
def test_master_with_class(self):
model = self.app.model
# nb. due to minimal test bootstrapping, no master views are
# registered by default at this point
self.assertNotIn("wuttaweb_master_views", self.request.registry.settings)
self.pyramid_config.add_wutta_master_view(MasterWithClass)
self.assertIn("wuttaweb_master_views", self.request.registry.settings)
master_views = self.request.registry.settings["wuttaweb_master_views"]
self.assertIn(model.User, master_views)
self.assertEqual(master_views[model.User], [MasterWithClass])
def test_master_with_name(self):
model = self.app.model
# nb. due to minimal test bootstrapping, no master views are
# registered by default at this point
self.assertNotIn("wuttaweb_master_views", self.request.registry.settings)
self.pyramid_config.add_wutta_master_view(MasterWithName)
self.assertIn("wuttaweb_master_views", self.request.registry.settings)
master_views = self.request.registry.settings["wuttaweb_master_views"]
self.assertIn("Widget", master_views)
self.assertEqual(master_views["Widget"], [MasterWithName])