Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit de088f7

Browse files
committed
add more type hints
1 parent 778929a commit de088f7

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

backend/tests/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@pytest.fixture(scope="session")
18-
def blob_with_data_container_name(blob_service_client):
18+
def blob_with_data_container_name(blob_service_client: BlobServiceClient):
1919
# create a storage container and upload some data
2020
container_name = "container-with-data"
2121
blob_service_client.create_container(container_name)
@@ -27,7 +27,7 @@ def blob_with_data_container_name(blob_service_client):
2727

2828

2929
@pytest.fixture(scope="session")
30-
def blob_service_client():
30+
def blob_service_client() -> Generator[BlobServiceClient, None, None]:
3131
blob_service_client = BlobServiceClient.from_connection_string(
3232
os.environ["STORAGE_CONNECTION_STRING"]
3333
)
@@ -36,7 +36,7 @@ def blob_service_client():
3636

3737

3838
@pytest.fixture(scope="session")
39-
def cosmos_client():
39+
def cosmos_client() -> Generator[CosmosClient, None, None]:
4040
""" "Initializes the CosmosDB databases that graphrag expects at startup time."""
4141
# setup
4242
client = CosmosClient.from_connection_string(os.environ["COSMOS_CONNECTION_STRING"])
@@ -53,7 +53,9 @@ def cosmos_client():
5353

5454

5555
@pytest.fixture(scope="session")
56-
def container_with_graphml_file(blob_service_client, cosmos_client):
56+
def container_with_graphml_file(
57+
blob_service_client: BlobServiceClient, cosmos_client: CosmosClient
58+
):
5759
"""create a storage container and upload a fake graphml file"""
5860
container_name = "container-with-graphml"
5961
sanitized_name = sanitize_name(container_name)
@@ -79,7 +81,9 @@ def container_with_graphml_file(blob_service_client, cosmos_client):
7981

8082

8183
@pytest.fixture(scope="session")
82-
def container_with_index_files(blob_service_client, cosmos_client):
84+
def container_with_index_files(
85+
blob_service_client: BlobServiceClient, cosmos_client: CosmosClient
86+
):
8387
"""create a storage container and upload a set of parquet files associated with a valid index"""
8488
container_name = "container-with-index-files"
8589
sanitized_name = sanitize_name(container_name)
@@ -122,6 +126,6 @@ def container_with_index_files(blob_service_client, cosmos_client):
122126

123127

124128
@pytest.fixture(scope="session")
125-
def client(request) -> Generator:
129+
def client(request) -> Generator[TestClient, None, None]:
126130
with TestClient(app) as c:
127131
yield c

backend/tests/integration/test_api_data.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
import os
88

9+
from azure.cosmos import CosmosClient
910

10-
def test_upload_files(cosmos_client, client):
11+
12+
def test_upload_files(cosmos_client: CosmosClient, client):
1113
"""Test uploading files to a data blob container."""
1214
# create a single file
1315
with open("test.txt", "wb") as f:
@@ -26,14 +28,14 @@ def test_upload_files(cosmos_client, client):
2628
os.remove("test.txt")
2729

2830

29-
def test_delete_files(cosmos_client, client):
31+
def test_delete_files(cosmos_client: CosmosClient, client):
3032
"""Test deleting a data blob container."""
3133
# delete a data blob container
3234
response = client.delete("/data/testContainer")
3335
assert response.status_code == 200
3436

3537

36-
def test_get_list_of_data_containers(cosmos_client, client):
38+
def test_get_list_of_data_containers(cosmos_client: CosmosClient, client):
3739
"""Test getting a list of all data blob containers."""
3840
response = client.get("/data")
3941
assert response.status_code == 200

backend/tests/integration/test_api_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77

8-
def test_get_graphml_file(client, container_with_graphml_file):
8+
def test_get_graphml_file(client, container_with_graphml_file: str):
99
"""Test retrieving a graphml file endpoint."""
1010
url = f"/graph/graphml/{container_with_graphml_file}"
1111
response = client.get(url)

backend/tests/integration/test_api_index.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
Integration tests for the /index API endpoints.
55
"""
66

7+
from azure.cosmos import CosmosClient
78

8-
def test_get_list_of_index_containers_empty(client, cosmos_client):
9+
10+
def test_get_list_of_index_containers_empty(client, cosmos_client: CosmosClient):
911
"""Test getting a list of all blob containers holding an index."""
1012
response = client.get("/index")
1113
assert response.status_code == 200
1214

1315

14-
def test_schedule_index_without_data(client, cosmos_client):
16+
def test_schedule_index_without_data(client, cosmos_client: CosmosClient):
1517
"""Test scheduling an index job with a non-existent data blob container."""
1618
response = client.post(
1719
"/index",

0 commit comments

Comments
 (0)