feat: add support for running via uvicorn; wutta webapp
command
This commit is contained in:
parent
3fabc0a141
commit
b6d5ffa8ce
13 changed files with 408 additions and 28 deletions
|
@ -1,8 +1,9 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
from wuttjamaican.testing import FileConfigTestCase
|
||||
from wuttjamaican.testing import FileTestCase, ConfigTestCase
|
||||
|
||||
from pyramid.config import Configurator
|
||||
from pyramid.router import Router
|
||||
|
@ -21,7 +22,7 @@ class TestWebAppProvider(TestCase):
|
|||
handler = app.get_web_handler()
|
||||
|
||||
|
||||
class TestMakeWuttaConfig(FileConfigTestCase):
|
||||
class TestMakeWuttaConfig(FileTestCase):
|
||||
|
||||
def test_config_path_required(self):
|
||||
|
||||
|
@ -51,7 +52,7 @@ class TestMakePyramidConfig(TestCase):
|
|||
self.assertIsInstance(config, Configurator)
|
||||
|
||||
|
||||
class TestMain(FileConfigTestCase):
|
||||
class TestMain(FileTestCase):
|
||||
|
||||
def test_basic(self):
|
||||
global_config = None
|
||||
|
@ -59,3 +60,43 @@ class TestMain(FileConfigTestCase):
|
|||
settings = {'wutta.config': myconf}
|
||||
app = mod.main(global_config, **settings)
|
||||
self.assertIsInstance(app, Router)
|
||||
|
||||
|
||||
def mock_main(global_config, **settings):
|
||||
|
||||
wutta_config = mod.make_wutta_config(settings)
|
||||
pyramid_config = mod.make_pyramid_config(settings)
|
||||
|
||||
pyramid_config.include('wuttaweb.static')
|
||||
pyramid_config.include('wuttaweb.subscribers')
|
||||
pyramid_config.include('wuttaweb.views')
|
||||
|
||||
return pyramid_config.make_wsgi_app()
|
||||
|
||||
|
||||
class TestMakeWsgiApp(ConfigTestCase):
|
||||
|
||||
def test_with_callable(self):
|
||||
|
||||
# specify config
|
||||
wsgi = mod.make_wsgi_app(mock_main, config=self.config)
|
||||
self.assertIsInstance(wsgi, Router)
|
||||
|
||||
# auto config
|
||||
with patch.object(mod, 'make_config', return_value=self.config):
|
||||
wsgi = mod.make_wsgi_app(mock_main)
|
||||
self.assertIsInstance(wsgi, Router)
|
||||
|
||||
def test_with_spec(self):
|
||||
|
||||
# specify config
|
||||
wsgi = mod.make_wsgi_app('tests.test_app:mock_main', config=self.config)
|
||||
self.assertIsInstance(wsgi, Router)
|
||||
|
||||
# auto config
|
||||
with patch.object(mod, 'make_config', return_value=self.config):
|
||||
wsgi = mod.make_wsgi_app('tests.test_app:mock_main')
|
||||
self.assertIsInstance(wsgi, Router)
|
||||
|
||||
def test_invalid(self):
|
||||
self.assertRaises(ValueError, mod.make_wsgi_app, 42, config=self.config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue