fix: add base class for WuttaList schema type
This commit is contained in:
parent
ceec4714fa
commit
24f7d7ac0a
2 changed files with 70 additions and 4 deletions
|
|
@ -280,13 +280,59 @@ class WuttaQuantity(colander.Decimal):
|
|||
return self.app.render_quantity(appstruct)
|
||||
|
||||
|
||||
class WuttaSet(colander.Set):
|
||||
class WuttaList(colander.List):
|
||||
"""
|
||||
Custom schema type for :class:`python:set` fields.
|
||||
|
||||
This is a subclass of :class:`colander.Set`.
|
||||
Custom schema type for :class:`python:list` fields; this is a
|
||||
subclass of :class:`colander.List`.
|
||||
|
||||
:param request: Current :term:`request` object.
|
||||
|
||||
As of now this merely provides a way (in fact, requires you) to
|
||||
pass the request in, so it can be leveraged as needed. Instances
|
||||
of this type will have the following attributes:
|
||||
|
||||
.. attribute:: request
|
||||
|
||||
Reference to the current :term:`request`.
|
||||
|
||||
.. attribute:: config
|
||||
|
||||
Reference to the app :term:`config object`.
|
||||
|
||||
.. attribute:: app
|
||||
|
||||
Reference to the :term:`app handler` instance.
|
||||
"""
|
||||
|
||||
def __init__(self, request):
|
||||
super().__init__()
|
||||
self.request = request
|
||||
self.config = self.request.wutta_config
|
||||
self.app = self.config.get_app()
|
||||
|
||||
|
||||
class WuttaSet(colander.Set):
|
||||
"""
|
||||
Custom schema type for :class:`python:set` fields; this is a
|
||||
subclass of :class:`colander.Set`.
|
||||
|
||||
:param request: Current :term:`request` object.
|
||||
|
||||
As of now this merely provides a way (in fact, requires you) to
|
||||
pass the request in, so it can be leveraged as needed. Instances
|
||||
of this type will have the following attributes:
|
||||
|
||||
.. attribute:: request
|
||||
|
||||
Reference to the current :term:`request`.
|
||||
|
||||
.. attribute:: config
|
||||
|
||||
Reference to the app :term:`config object`.
|
||||
|
||||
.. attribute:: app
|
||||
|
||||
Reference to the :term:`app handler` instance.
|
||||
"""
|
||||
|
||||
def __init__(self, request):
|
||||
|
|
|
|||
|
|
@ -198,6 +198,26 @@ class TestWuttaMoney(WebTestCase):
|
|||
self.assertEqual(widget.scale, 4)
|
||||
|
||||
|
||||
class TestWuttaList(WebTestCase):
|
||||
|
||||
def test_constructor(self):
|
||||
node = colander.SchemaNode(mod.WuttaList(self.request))
|
||||
typ = node.typ
|
||||
self.assertIs(typ.request, self.request)
|
||||
self.assertIs(typ.config, self.config)
|
||||
self.assertIs(typ.app, self.app)
|
||||
|
||||
|
||||
class TestWuttaSet(WebTestCase):
|
||||
|
||||
def test_constructor(self):
|
||||
node = colander.SchemaNode(mod.WuttaSet(self.request))
|
||||
typ = node.typ
|
||||
self.assertIs(typ.request, self.request)
|
||||
self.assertIs(typ.config, self.config)
|
||||
self.assertIs(typ.app, self.app)
|
||||
|
||||
|
||||
class TestWuttaQuantity(WebTestCase):
|
||||
|
||||
def test_serialize(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue