async def load_cookie(client: TestClient,
                      redis: aioredis.commands.Redis) -> Any:
    cookies = client.session.cookie_jar.filter_cookies(client.make_url('/'))
    key = cookies['AIOHTTP_SESSION']
    with await redis as conn:
        encoded = await conn.get('AIOHTTP_SESSION_' + key.value)
        s = encoded.decode('utf-8')
        value = json.loads(s)
        return value
async def load_cookie(
    client: TestClient,
    memcached: aiomcache.Client
) -> Any:
    cookies = client.session.cookie_jar.filter_cookies(client.make_url('/'))
    key = cookies['AIOHTTP_SESSION']
    storage_key = ('AIOHTTP_SESSION_' + key.value).encode('utf-8')
    encoded = await memcached.get(storage_key)
    s = encoded.decode('utf-8')
    value = json.loads(s)
    return value
Esempio n. 3
0
 def run(self):
     try:
         backend = Backend(graph_path=str(TEST_GRAPH_PATH))
         with backend:
             with loop_context() as loop:
                 app = make_app(backend=backend, debug=True)
                 client = TestClient(TestServer(app), loop=loop)
                 loop.run_until_complete(client.start_server())
                 url = client.make_url("/graph/")
                 self.q.put(url)
                 loop.run_forever()
     except Exception as e:
         self.q.put(e)