Ejemplo n.º 1
0
        def cb():
            def read():
                fut = asyncio.Future(loop=self._loop)
                with open(filename) as f:
                    fut.set_result(f.read().encode('utf-8'))
                return fut

            resp = ClientResponse('GET',
                                  yarl.URL(uri),
                                  writer=Mock(),
                                  timer=TimerNoop(),
                                  continue100=None,
                                  request_info=Mock(),
                                  traces=[],
                                  loop=self._loop,
                                  session=Mock())
            resp._headers = {'Content-Type': 'application/json'}

            resp.status = status
            resp.reason = Mock()
            resp.content = Mock()
            resp.content.read.side_effect = read
            resp.close = Mock()
            fut = asyncio.Future(loop=self._loop)
            fut.set_result(resp)
            return fut
Ejemplo n.º 2
0
        def cb():
            def read():
                fut = asyncio.Future(loop=self._loop)
                with open(filename) as f:
                    fut.set_result(f.read().encode("utf-8"))
                return fut

            resp = ClientResponse("GET", uri)
            resp.headers = {"Content-Type": "application/json"}

            resp.status = 200
            resp.content = Mock()
            resp.content.read.side_effect = read
            resp.close = Mock()
            fut = asyncio.Future(loop=self._loop)
            fut.set_result(resp)
            return fut
Ejemplo n.º 3
0
        def cb():
            def read():
                fut = asyncio.Future(loop=self._loop)
                with open(filename) as f:
                    fut.set_result(f.read().encode('utf-8'))
                return fut

            resp = ClientResponse('GET', yarl.URL(uri))
            resp.headers = {'Content-Type': 'application/json'}

            resp.status = status
            resp.content = Mock()
            resp.content.read.side_effect = read
            resp.close = Mock()
            fut = asyncio.Future(loop=self._loop)
            fut.set_result(resp)
            return fut
Ejemplo n.º 4
0
        def cb():
            fut = asyncio.Future(loop=self._loop)
            resp = ClientResponse('GET',
                                  yarl.URL('foo'),
                                  writer=Mock(),
                                  timer=TimerNoop(),
                                  continue100=None,
                                  request_info=Mock(),
                                  traces=[],
                                  loop=self._loop,
                                  session=Mock())
            resp.status = status

            # setting this as aiohttp 3.5.4 is now checking if this value is not None
            # see aiohttp/client_reqrep.py:934
            resp.reason = http.client.responses[status]

            fut.set_result(resp)
            return fut
Ejemplo n.º 5
0
 def cb():
     fut = asyncio.Future(loop=self._loop)
     resp = ClientResponse("GET", "foo")
     resp.status = status
     fut.set_result(resp)
     return fut
Ejemplo n.º 6
0
 def cb():
     fut = asyncio.Future(loop=self._loop)
     resp = ClientResponse('GET', yarl.URL('foo'))
     resp.status = status
     fut.set_result(resp)
     return fut