Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert TestService.DATA
assert TestService.DATA == [b'hello server\n']
def test_aiohttp_service_create_app():
with pytest.raises(TypeError):
class _(AIOHTTPService):
def create_application(self):
return None
class _(AIOHTTPService):
async def create_application(self):
return aiohttp.web.Application()
class AIOHTTPTestApp(AIOHTTPService):
async def create_application(self):
return aiohttp.web.Application()
def test_aiohttp_service_without_port_or_sock(aiomisc_unused_port):
with pytest.raises(RuntimeError):
AIOHTTPService()
def test_aiohttp_service(aiomisc_unused_port):
@aiomisc.threaded
def http_client():
conn = http.client.HTTPConnection(
host='127.0.0.1',
port=aiomisc_unused_port,
timeout=1
def test_aiohttp_service_without_port_or_sock(aiomisc_unused_port):
with pytest.raises(RuntimeError):
AIOHTTPService()
def test_aiohttp_service_create_app():
with pytest.raises(TypeError):
class _(AIOHTTPService):
def create_application(self):
return None
class _(AIOHTTPService):
async def create_application(self):
return aiohttp.web.Application()
)
await self.runner.setup()
self.site = await self.create_site()
await self.site.start()
async def stop(self, exception: Exception = None):
try:
await self.site.stop()
finally:
await self.runner.cleanup()
class AIOHTTPSSLService(AIOHTTPService):
def __init__(self, cert: PathOrStr, key: PathOrStr, ca: PathOrStr = None,
address: str = None, port: int = None, verify: bool = True,
sock: socket.socket = None, shutdown_timeout: int = 5,
require_client_cert: bool = False, **kwds):
super().__init__(
address=address, port=port, sock=sock,
shutdown_timeout=shutdown_timeout, **kwds
)
self.__ssl_options = cert, key, ca, verify, require_client_cert
async def create_site(self):
return SockSite(
self.runner, self.socket,
shutdown_timeout=self.shutdown_timeout,