3
0
Fork 0

feat: add Users view; improve CRUD master for SQLAlchemy models

This commit is contained in:
Lance Edgar 2024-08-12 21:17:08 -05:00
parent 33589f1cd8
commit eac3b81918
33 changed files with 1510 additions and 253 deletions

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8; -*-
import colander
import deform
from pyramid import testing
from wuttaweb.forms import widgets
from wuttaweb.forms.schema import PersonRef
from tests.util import WebTestCase
class TestObjectRefWidget(WebTestCase):
def test_serialize(self):
model = self.app.model
person = model.Person(full_name="Betty Boop")
self.session.add(person)
self.session.commit()
# standard (editable)
node = colander.SchemaNode(PersonRef(self.request, session=self.session))
widget = widgets.ObjectRefWidget(self.request)
field = deform.Field(node)
html = widget.serialize(field, person.uuid)
self.assertIn('<select ', html)
# readonly
node = colander.SchemaNode(PersonRef(self.request, session=self.session))
node.model_instance = person
widget = widgets.ObjectRefWidget(self.request)
field = deform.Field(node)
html = widget.serialize(field, person.uuid, readonly=True)
self.assertEqual(html, '<span>Betty Boop</span>')