Add generic handler base class, tests, docs
This commit is contained in:
parent
27a90b2a87
commit
d73ff274df
|
@ -281,3 +281,19 @@ class AppProvider:
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.app = config.get_app()
|
self.app = config.get_app()
|
||||||
|
|
||||||
|
|
||||||
|
class GenericHandler:
|
||||||
|
"""
|
||||||
|
Generic base class for handlers.
|
||||||
|
|
||||||
|
When the :term:`app` defines a new *type* of :term:`handler` it
|
||||||
|
may subclass this when defining the handler base class.
|
||||||
|
|
||||||
|
:param config: Config object for the app. This should be an
|
||||||
|
instance of :class:`~wuttjamaican.conf.WuttaConfig`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, config, **kwargs):
|
||||||
|
self.config = config
|
||||||
|
self.app = self.config.get_app()
|
||||||
|
|
|
@ -188,3 +188,16 @@ class TestAppProvider(TestCase):
|
||||||
# but provider can supply the attr
|
# but provider can supply the attr
|
||||||
self.app.providers['mytest'] = MagicMock(foo_value='bar')
|
self.app.providers['mytest'] = MagicMock(foo_value='bar')
|
||||||
self.assertEqual(self.app.foo_value, 'bar')
|
self.assertEqual(self.app.foo_value, 'bar')
|
||||||
|
|
||||||
|
|
||||||
|
class TestGenericHandler(TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.config = WuttaConfig(appname='wuttatest')
|
||||||
|
self.app = app.AppHandler(self.config)
|
||||||
|
self.config.app = self.app
|
||||||
|
|
||||||
|
def test_constructor(self):
|
||||||
|
handler = app.GenericHandler(self.config)
|
||||||
|
self.assertIs(handler.config, self.config)
|
||||||
|
self.assertIs(handler.app, self.app)
|
||||||
|
|
Loading…
Reference in a new issue