feat: add basic MasterView to show all registered master views
also serves as anchor for "make new master view" feature, coming soon
This commit is contained in:
parent
21775257a9
commit
92d4ce43b1
8 changed files with 222 additions and 0 deletions
46
tests/views/test_views.py
Normal file
46
tests/views/test_views.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from wuttaweb.testing import WebTestCase
|
||||
from wuttaweb.views import views as mod
|
||||
from wuttaweb.views.users import UserView
|
||||
|
||||
|
||||
class TestMasterViewView(WebTestCase):
|
||||
|
||||
def make_view(self):
|
||||
return mod.MasterViewView(self.request)
|
||||
|
||||
def test_includeme(self):
|
||||
self.pyramid_config.include("wuttaweb.views.views")
|
||||
|
||||
def test_get_grid_data(self):
|
||||
view = self.make_view()
|
||||
|
||||
# empty by default, since nothing registered in test setup
|
||||
data = view.get_grid_data()
|
||||
self.assertIsInstance(data, list)
|
||||
self.assertEqual(len(data), 0)
|
||||
|
||||
# so let's register one and try again
|
||||
self.pyramid_config.add_wutta_master_view(UserView)
|
||||
data = view.get_grid_data()
|
||||
self.assertGreater(len(data), 0)
|
||||
master = data[0]
|
||||
self.assertIsInstance(master, dict)
|
||||
self.assertEqual(master["model_title_plural"], "Users")
|
||||
self.assertEqual(master["model_name"], "User")
|
||||
self.assertEqual(master["url_prefix"], "/users")
|
||||
|
||||
def test_configure_grid(self):
|
||||
self.pyramid_config.add_route("users", "/users/")
|
||||
self.pyramid_config.add_wutta_master_view(UserView)
|
||||
view = self.make_view()
|
||||
|
||||
# sanity / coverage check
|
||||
grid = view.make_grid(
|
||||
columns=["model_title_plural", "url_prefix"], data=view.get_grid_data()
|
||||
)
|
||||
view.configure_grid(grid)
|
||||
|
||||
# nb. must invoke this to exercise the url logic
|
||||
grid.get_vue_context()
|
||||
Loading…
Add table
Add a link
Reference in a new issue