Skip to content

Commit 723be32

Browse files
committed
More tests, Windows check
1 parent 9c11ee6 commit 723be32

File tree

4 files changed

+8
-36
lines changed

4 files changed

+8
-36
lines changed

.github/workflows/python-test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ jobs:
6262
- name: Check formatting with black
6363
run: black . --check --verbose
6464
- name: Run Python tests
65+
if: runner.os != 'Windows'
6566
run: pytest -s -vv --cov --cov-report=xml --cov-fail-under=90
6667
- name: Check diff coverage
68+
if: runner.os != 'Windows'
6769
run: |
6870
git fetch origin main:refs/remotes/origin/main
6971
diff-cover coverage.xml --compare-branch=origin/main --fail-under=90

tests/mocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ async def __aexit__(self, *args):
108108
pass
109109

110110
async def open(self):
111-
pass
111+
pass # pragma: no cover
112112

113113
async def close(self):
114-
pass
114+
pass # pragma: no cover
115115

116116

117117
class MockAsyncPageIterator:

tests/test_blob_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async def test_dont_remove_if_no_container(
166166
monkeypatch, mock_env, mock_blob_container_client_does_not_exist, blob_manager
167167
):
168168
async def mock_delete_blob(*args, **kwargs):
169-
assert False, "delete_blob() shouldn't have been called"
169+
assert False, "delete_blob() shouldn't have been called" # pragma: no cover
170170

171171
monkeypatch.setattr("azure.storage.blob.aio.ContainerClient.delete_blob", mock_delete_blob)
172172

@@ -377,7 +377,7 @@ def __init__(self):
377377
self.properties = None # This is the condition we're testing
378378

379379
async def readall(self):
380-
return b"This content should not be returned"
380+
assert False, "This should not be called, as properties is None" # pragma: no cover
381381

382382
async def mock_download_blob(*args, **kwargs):
383383
return MockDownloadResponseWithNoProperties()

tests/test_searchmanager.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ async def mock_create_index(self, index):
508508

509509
async def mock_list_index_names(self):
510510
for index in []:
511-
yield index
511+
yield index # pragma: no cover
512512

513513
monkeypatch.setattr(SearchIndexClient, "create_index", mock_create_index)
514514
monkeypatch.setattr(SearchIndexClient, "list_index_names", mock_list_index_names)
@@ -562,17 +562,6 @@ async def mock_list_index_names(self):
562562
@pytest.mark.asyncio
563563
async def test_create_index_with_search_images_no_endpoint(monkeypatch, search_info):
564564
"""Test that SearchManager raises an error when search_images=True but no Azure Vision endpoint is provided."""
565-
indexes = []
566-
567-
async def mock_create_index(self, index):
568-
indexes.append(index)
569-
570-
async def mock_list_index_names(self):
571-
for index in []:
572-
yield index
573-
574-
monkeypatch.setattr(SearchIndexClient, "create_index", mock_create_index)
575-
monkeypatch.setattr(SearchIndexClient, "list_index_names", mock_list_index_names)
576565

577566
# Create a SearchManager with search_images=True but no Azure Vision endpoint
578567
manager = SearchManager(
@@ -599,25 +588,7 @@ async def mock_create_index(self, index):
599588

600589
async def mock_list_index_names(self):
601590
for index in []:
602-
yield index
603-
604-
async def mock_create_client(*args, **kwargs):
605-
return MockClient(
606-
embeddings_client=MockEmbeddingsClient(
607-
create_embedding_response=openai.types.CreateEmbeddingResponse(
608-
object="list",
609-
data=[
610-
openai.types.Embedding(
611-
embedding=[0.1, 0.2, 0.3],
612-
index=0,
613-
object="embedding",
614-
)
615-
],
616-
model=MOCK_EMBEDDING_MODEL_NAME,
617-
usage=Usage(prompt_tokens=8, total_tokens=8),
618-
)
619-
)
620-
)
591+
yield index # pragma: no cover
621592

622593
monkeypatch.setattr(SearchIndexClient, "create_index", mock_create_index)
623594
monkeypatch.setattr(SearchIndexClient, "list_index_names", mock_list_index_names)
@@ -640,7 +611,6 @@ async def mock_create_client(*args, **kwargs):
640611
credential=AzureKeyCredential("test"),
641612
disable_batch=True,
642613
)
643-
monkeypatch.setattr(embeddings, "create_client", mock_create_client)
644614

645615
# Create a SearchManager with both search_images and embeddings
646616
manager = SearchManager(

0 commit comments

Comments
 (0)