feat: add basic support for running in ASGI context
This commit is contained in:
parent
b6d5ffa8ce
commit
a132253cb1
3 changed files with 44 additions and 0 deletions
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
|||
|
||||
from wuttjamaican.testing import FileTestCase, ConfigTestCase
|
||||
|
||||
from asgiref.wsgi import WsgiToAsgi
|
||||
from pyramid.config import Configurator
|
||||
from pyramid.router import Router
|
||||
|
||||
|
@ -100,3 +101,31 @@ class TestMakeWsgiApp(ConfigTestCase):
|
|||
|
||||
def test_invalid(self):
|
||||
self.assertRaises(ValueError, mod.make_wsgi_app, 42, config=self.config)
|
||||
|
||||
|
||||
class TestMakeAsgiApp(ConfigTestCase):
|
||||
|
||||
def test_with_callable(self):
|
||||
|
||||
# specify config
|
||||
asgi = mod.make_asgi_app(mock_main, config=self.config)
|
||||
self.assertIsInstance(asgi, WsgiToAsgi)
|
||||
|
||||
# auto config
|
||||
with patch.object(mod, 'make_config', return_value=self.config):
|
||||
asgi = mod.make_asgi_app(mock_main)
|
||||
self.assertIsInstance(asgi, WsgiToAsgi)
|
||||
|
||||
def test_with_spec(self):
|
||||
|
||||
# specify config
|
||||
asgi = mod.make_asgi_app('tests.test_app:mock_main', config=self.config)
|
||||
self.assertIsInstance(asgi, WsgiToAsgi)
|
||||
|
||||
# auto config
|
||||
with patch.object(mod, 'make_config', return_value=self.config):
|
||||
asgi = mod.make_asgi_app('tests.test_app:mock_main')
|
||||
self.assertIsInstance(asgi, WsgiToAsgi)
|
||||
|
||||
def test_invalid(self):
|
||||
self.assertRaises(ValueError, mod.make_asgi_app, 42, config=self.config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue