Skip to content

Commit

Permalink
shut the pep8 bot up
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Nov 5, 2018
1 parent 8c7f9b1 commit 816e5c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion matrix_client/_api_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ async def get_room_displayname(self, room_id, user_id):
for mem in members:
if mem['sender'] == user_id:
return mem['content']['displayname']

2 changes: 1 addition & 1 deletion matrix_client/api_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
else:
from ._api_asyncio import AsyncHTTPAPI

__all__ = ['AsyncHttpApi']
__all__ = ['AsyncHTTPAPI']
4 changes: 4 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import sys

if sys.version_info < (3, 5):
collect_ignore = ["test_async_api.py"]
17 changes: 8 additions & 9 deletions test/test_async_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa E501
import json
from asyncio import Future
from functools import partial
Expand All @@ -17,6 +18,7 @@ def client_session(json, status=200):

class MockResponse(MagicMock):
called = 0

async def __aenter__(self):
response = MagicMock()
f = Future()
Expand All @@ -38,11 +40,11 @@ def status(self):
self.called += 1
return status


client_session.request = MockResponse()

return client_session


@pytest.fixture
def api():
return partial(AsyncHTTPAPI, base_url="http://base_url", token="1234")
Expand All @@ -52,7 +54,7 @@ def api():
async def test_send(api):
api = api(client_session=client_session({}))

response = await api._send("GET", "/createRoom")
await api._send("GET", "/createRoom")
api.client_session.request.assert_called_once_with("GET",
"http://base_url/_matrix/client/r0/createRoom",
data="{}",
Expand All @@ -64,7 +66,7 @@ async def test_send(api):
async def test_send_429(api):
api = api(client_session=client_session({}, status=429))

response = await api._send("GET", "/createRoom")
await api._send("GET", "/createRoom")
call429 = call("GET",
"http://base_url/_matrix/client/r0/createRoom",
data="{}",
Expand All @@ -75,15 +77,14 @@ async def test_send_429(api):
api.client_session.request.assert_has_calls([call429, call429])



@pytest.mark.parametrize("json", [{"error": '{"retry_after_ms": 10}'},
{"error": {"retry_after_ms": 10}},
{"retry_after_ms": 10}])
@pytest.mark.asyncio
async def test_send_429_timeout(api, json):
api = api(client_session=client_session(json, status=429))

response = await api._send("GET", "/createRoom")
await api._send("GET", "/createRoom")

call429 = call("GET",
"http://base_url/_matrix/client/r0/createRoom",
Expand All @@ -100,7 +101,7 @@ async def test_send_404(api):
api = api(client_session=client_session({}, status=404))

with pytest.raises(matrix_client.errors.MatrixRequestError) as exc:
response = await api._send("GET", "/createRoom")
await api._send("GET", "/createRoom")
assert exc.status == 404
assert exc.content == "hello"

Expand Down Expand Up @@ -149,7 +150,6 @@ async def test_get_avatar_url(api):
@pytest.mark.asyncio
async def test_get_room_id(api):
api = api(client_session=client_session({"room_id": "aroomid"}))
mxid = "@user:test"
room_alias = "#test:test"
aid = await api.get_room_id(room_alias)
assert aid == "aroomid"
Expand All @@ -166,7 +166,6 @@ async def test_get_room_displayname(api):
mxid = "@user:test"
api = api(client_session=client_session({"chunk":
[{"sender": mxid, "content": {"displayname": "African swallow"}}]}))
room_alias = "#test:test"
displayname = await api.get_room_displayname("arromid", mxid)
assert displayname == "African swallow"

Expand All @@ -183,7 +182,7 @@ async def test_sync_wrap(api):
api = api(client_session=client_session({}))
roomid = "!ldjaslkdja:test"
eventid = "$alskdjsalkdjal:test"
displayname = await api.get_event_in_room(roomid, eventid)
await api.get_event_in_room(roomid, eventid)

api.client_session.request.assert_called_once_with("GET",
f"http://base_url/_matrix/client/r0/rooms/{roomid}/event/{eventid}",
Expand Down

0 comments on commit 816e5c3

Please sign in to comment.