Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/backend/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ azure-ai-documentintelligence==1.0.0b4
azure-cognitiveservices-speech
azure-cosmos
azure-search-documents==11.7.0b1
azure-storage-blob
azure-storage-blob==12.27.0
azure-storage-file-datalake
uvicorn
aiohttp
Expand Down
2 changes: 1 addition & 1 deletion app/backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ azure-monitor-opentelemetry-exporter==1.0.0b44
# via azure-monitor-opentelemetry
azure-search-documents==11.7.0b1
# via -r requirements.in
azure-storage-blob==12.22.0
azure-storage-blob==12.27.0
# via
# -r requirements.in
# azure-storage-file-datalake
Expand Down
27 changes: 27 additions & 0 deletions tests/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ async def readinto(self, buffer: BytesIO):
buffer.write(b"test")


class MockContentReader:
"""Mock content reader for aiohttp.ClientResponse"""
def __init__(self, body_bytes):
self._body = body_bytes
self._offset = 0
self._exception = None

async def read(self, n=-1):
if n == -1:
result = self._body[self._offset:]
self._offset = len(self._body)
else:
result = self._body[self._offset:self._offset + n]
self._offset += len(result)
return result

def exception(self):
return self._exception

def set_exception(self, exc):
self._exception = exc


class MockAiohttpClientResponse404(aiohttp.ClientResponse):
def __init__(self, url, body_bytes, headers=None):
self._body = body_bytes
Expand All @@ -83,6 +106,8 @@ def __init__(self, url, body_bytes, headers=None):
self.status = 404
self.reason = "Not Found"
self._url = url
self._loop = None
self.content = MockContentReader(body_bytes)


class MockAiohttpClientResponse(aiohttp.ClientResponse):
Expand All @@ -93,6 +118,8 @@ def __init__(self, url, body_bytes, headers=None):
self.status = 200
self.reason = "OK"
self._url = url
self._loop = None
self.content = MockContentReader(body_bytes)


class MockTransport(AsyncHttpTransport):
Expand Down