aiohttp-security/tests/test_no_identity.py

43 lines
1.2 KiB
Python
Raw Normal View History

import asyncio
from aiohttp import web
from aiohttp_security import remember, forget
2016-09-27 14:57:11 +00:00
@asyncio.coroutine
def test_remember(loop, test_client):
@asyncio.coroutine
def do_remember(request):
response = web.Response()
yield from remember(request, response, 'Andrew')
2016-09-27 14:57:11 +00:00
app = web.Application(loop=loop)
app.router.add_route('POST', '/', do_remember)
2016-09-27 14:57:11 +00:00
client = yield from test_client(app)
resp = yield from client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)
yield from resp.release()
2016-09-27 14:57:11 +00:00
@asyncio.coroutine
def test_forget(loop, test_client):
@asyncio.coroutine
def do_forget(request):
response = web.Response()
yield from forget(request, response)
2016-09-27 14:57:11 +00:00
app = web.Application(loop=loop)
app.router.add_route('POST', '/', do_forget)
2016-09-27 14:57:11 +00:00
client = yield from test_client(app)
resp = yield from client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)
yield from resp.release()