Skip to content

Commit

Permalink
Merge pull request #293 from socotecio/fix-stream-tests
Browse files Browse the repository at this point in the history
fix: StreamResponse tests
  • Loading branch information
AMontagu authored May 13, 2024
2 parents b68e7a6 + 03c3e0f commit 422fb3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions django_socio_grpc/tests/grpc_test_utils/fake_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ def __await__(self):
class StreamRequestMixin:
_is_done_writing = False
request = None
_context: FakeAsyncContext

def __call__(self, request=None, metadata=None):
print("__call__", request)
return super().__call__(
request=FakeMessageReceiver(request=request, context=self._context),
metadata=metadata,
Expand All @@ -392,20 +392,21 @@ async def done_writing(self) -> None:


class StreamResponseMixin:
_context: FakeAsyncContext

def __aiter__(self):
return self

async def __anext__(self):
# INFO - AM - 05/01/2024 - do not use self.read here. Don't know why (mostly because of mixed inheritance and read client instead of server pipe) but it break everything
response = await self._context.read_server()
response = await self.read()
if isinstance(response, Exception):
raise response
if response == grpc.aio.EOF:
raise StopAsyncIteration()
return response

async def read(self):
return await self._context._read_server()
return await self._context.read_server()


class FakeFullAioStreamUnaryCall(
Expand Down

0 comments on commit 422fb3c

Please sign in to comment.