Skip to content

Commit

Permalink
Merge 5bcd237 into 7e19516
Browse files Browse the repository at this point in the history
  • Loading branch information
f0t0n committed Apr 16, 2016
2 parents 7e19516 + 5bcd237 commit 1b76820
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/test_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ def error(method):
}


def msg():
def _msg(request):
return request.param
return _msg


def assert_send_bytes_called(ws, resp):
assert not ws.send_str.called
ws.send_bytes.assert_called_with(msgpack.dumps(resp))


def assert_send_str_called(ws, resp):
assert not ws.send_bytes.called
ws.send_str.assert_called_with(json.dumps(resp))


def create_request(service):
return {
'method': service,
Expand Down Expand Up @@ -91,8 +107,6 @@ def valid_msg_params_binary():
def valid_msg_params_text():
return [
create_msg(aiohttp.MsgType.text, text_rpc_call()),
# create_msg(aiohttp.MsgType.text, 'close'),
# create_msg(aiohttp.MsgType.error, None),
]


Expand Down Expand Up @@ -131,12 +145,6 @@ def ws():
return ws


def msg():
def _msg(request):
return request.param
return _msg


@pytest.fixture(scope='function')
def msg_close():
return create_msg(aiohttp.MsgType.text, 'close')
Expand All @@ -160,16 +168,6 @@ def services(test_service):
return {test_service.__name__: test_service()}


def assert_send_bytes_called(ws, resp):
assert not ws.send_str.called
ws.send_bytes.assert_called_with(msgpack.dumps(resp))


def assert_send_str_called(ws, resp):
assert not ws.send_bytes.called
ws.send_str.assert_called_with(json.dumps(resp))


@pytest.mark.asyncio
async def test_msg_handler_with_valid_msg_binary(msg_handler, ws,
valid_msg_binary, services):
Expand Down

0 comments on commit 1b76820

Please sign in to comment.