feat: refactor forms/grids/views/templates per wuttaweb compat

this starts to get things more aligned between wuttaweb and tailbone.
the use case in mind so far is for a wuttaweb view to be included in a
tailbone app.

form and grid classes now have some new methods to match wuttaweb, so
templates call the shared method names where possible.

templates can no longer assume they have tailbone-native master view,
form, grid etc. so must inspect context more closely in some cases.
This commit is contained in:
Lance Edgar 2024-08-15 14:34:20 -05:00
parent b53479f8e4
commit a6ce5eb21d
39 changed files with 1037 additions and 300 deletions
tests/views

33
tests/views/test_users.py Normal file
View file

@ -0,0 +1,33 @@
# -*- coding: utf-8; -*-
from unittest.mock import patch, MagicMock
from tailbone.views import users as mod
from tailbone.views.principal import PermissionsRenderer
from tests.util import WebTestCase
class TestUserView(WebTestCase):
def make_view(self):
return mod.UserView(self.request)
def test_includeme(self):
self.pyramid_config.include('tailbone.views.users')
def test_configure_form(self):
self.pyramid_config.include('tailbone.views.users')
model = self.app.model
barney = model.User(username='barney')
self.session.add(barney)
self.session.commit()
view = self.make_view()
# must use mock configure when making form
def configure(form): pass
form = view.make_form(instance=barney, configure=configure)
with patch.object(view, 'viewing', new=True):
self.assertNotIn('permissions', form.renderers)
view.configure_form(form)
self.assertIsInstance(form.renderers['permissions'], PermissionsRenderer)