Skip to content

Commit

Permalink
fix(Client.py): spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Dec 7, 2018
1 parent d15a45c commit 3dff445
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/comms/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def send(self, request: Request) -> Future:
return future


def recieve(self, response: Response) -> None:
def receive(self, response: Response) -> None:
"""
Receive a request from the server.
Expand All @@ -74,6 +74,7 @@ def recieve(self, response: Response) -> None:
:param: response The JSON-RPC response as a string or Response instance
"""
assert response.id
future = self.futures.get(response.id)
if not future:
raise RuntimeError(f'No request found for response with id: {response.id}')
Expand Down Expand Up @@ -107,11 +108,13 @@ def decode(self, message: str) -> Response:
# Convert the message into a response
# Currently this only deals with JSON messages but in the furture
# should handle other message formats
return Response(**json.loads(message))
response = Response()
response.__dict__.update(json.loads(message))
return response

async def read(self, message: str) -> None:
# Recieve a response message
self.recieve(self.decode(message))
self.receive(self.decode(message))

async def write(self, message: str) -> None:
raise NotImplementedError()
4 changes: 2 additions & 2 deletions tests/comms/ClientTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from stencilaschema.comms.jsonRpc import Request, Response

@pytest.mark.asyncio
async def test_recieve():
async def test_receive():
client = Client()

async def write(message):
pass
client.write = write

future = await client.send(Request(method="compile", id=1))
client.recieve(Response(id=1, result={"type": "Thing"}))
client.receive(Response(id=1, result={"type": "Thing"}))
response = await future
assert response.result == {"type": "Thing"}

0 comments on commit 3dff445

Please sign in to comment.