Skip to content

Commit

Permalink
Merge pull request #27 from onna/fix-streamreader
Browse files Browse the repository at this point in the history
Fix streamreader init
  • Loading branch information
marcus29200 authored Oct 26, 2020
2 parents 1f09e55 + 8360e88 commit 7ca10d3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

2.1.1
-----

- Add required parameter to streamreader

2.1.0
-----

Expand Down
3 changes: 2 additions & 1 deletion cassettedeck/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from aiohttp import hdrs
from aiohttp.helpers import TimerNoop
from unittest.mock import Mock
from cassettedeck.store import DEFAULT_STREAM_LIMIT
import json
import asyncio

Expand Down Expand Up @@ -66,7 +67,7 @@ async def build_response(self, session, method, url,
resp._headers = CIMultiDict({hdrs.CONTENT_TYPE: ct})
loop = asyncio.get_event_loop()
protocol = Mock(_reading_paused=False)
resp.content = StreamReader(protocol, loop=loop)
resp.content = StreamReader(protocol, loop=loop, limit=DEFAULT_STREAM_LIMIT)
if isinstance(data, str):
data = data.encode('utf8')
resp.content.feed_data(data)
Expand Down
4 changes: 3 additions & 1 deletion cassettedeck/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

default_library = os.path.join(os.path.dirname(__file__), 'cassettes/')

DEFAULT_STREAM_LIMIT = 6 ** 16


class CassetteStore(object):
"""This class wraps all logic related to cassettes, such as storing
Expand Down Expand Up @@ -176,7 +178,7 @@ def build_response(self, method, url, params, data, headers):

# Set headers and content
resp._headers = CIMultiDict(resp_json['headers'])
resp.content = StreamReader(Mock())
resp.content = StreamReader(Mock(), limit=DEFAULT_STREAM_LIMIT)

# Get the data
data = resp_json['body']['data']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='cassettedeck',
version='2.1.0',
version='2.1.1',
description='A library store and replay aiohttp requests',
long_description='To simplify and speed up tests that make HTTP requests',
author='Developer team at Onna Technologies',
Expand Down

0 comments on commit 7ca10d3

Please sign in to comment.