Skip to content

Commit c513e8f

Browse files
committed
Fix formatting, import sorting, and lint issues in tests
Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
1 parent 81f5ebf commit c513e8f

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

tests/test_client.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
MarketLocationRef,
2828
MarketLocationSample,
2929
MarketLocationSeries,
30-
MarketLocationUpdate,
3130
MarketLocationsFilter,
31+
MarketLocationUpdate,
3232
MetricType,
3333
MetricUnit,
3434
PaginationParams,
@@ -46,8 +46,10 @@ def _make_client() -> MarketMeteringApiClient:
4646
connect=False,
4747
)
4848
# Inject a mock stub so we don't need a real connection.
49+
# pylint: disable=protected-access
4950
client._stub = MagicMock() # noqa: SLF001
5051
client._channel = MagicMock() # noqa: SLF001
52+
# pylint: enable=protected-access
5153
return client
5254

5355

@@ -449,9 +451,9 @@ async def test_yields_parsed_series(self) -> None:
449451
response = pb.ReceiveMarketLocationSamplesStreamResponse(series=[series_pb])
450452

451453
# Mock the streaming call to return an async iterator.
452-
async def mock_stream() -> AsyncIterator[
453-
pb.ReceiveMarketLocationSamplesStreamResponse
454-
]:
454+
async def mock_stream() -> (
455+
AsyncIterator[pb.ReceiveMarketLocationSamplesStreamResponse]
456+
):
455457
yield response
456458

457459
client.stub.ReceiveMarketLocationSamplesStream = MagicMock(
@@ -477,9 +479,9 @@ async def test_sends_time_filter(self) -> None:
477479
"""Test that start_time and end_time are sent."""
478480
client = _make_client()
479481

480-
async def mock_stream() -> AsyncIterator[
481-
pb.ReceiveMarketLocationSamplesStreamResponse
482-
]:
482+
async def mock_stream() -> (
483+
AsyncIterator[pb.ReceiveMarketLocationSamplesStreamResponse]
484+
):
483485
return
484486
yield # make it an async generator # noqa: RET504
485487

@@ -534,9 +536,9 @@ async def test_yields_parsed_results(self) -> None:
534536
error_code=pb.SAMPLE_UPSERT_ERROR_CODE_UNSPECIFIED,
535537
)
536538

537-
async def mock_stream() -> AsyncIterator[
538-
pb.UpsertMarketLocationSamplesStreamResponse
539-
]:
539+
async def mock_stream() -> (
540+
AsyncIterator[pb.UpsertMarketLocationSamplesStreamResponse]
541+
):
540542
yield upsert_response
541543

542544
client.stub.UpsertMarketLocationSamplesStream = MagicMock(
@@ -562,9 +564,9 @@ async def mock_stream() -> AsyncIterator[
562564
samples=[sample],
563565
)
564566

565-
async def input_stream() -> AsyncIterator[
566-
tuple[MarketLocationRef, MarketLocationSeries]
567-
]:
567+
async def input_stream() -> (
568+
AsyncIterator[tuple[MarketLocationRef, MarketLocationSeries]]
569+
):
568570
yield (ml_ref, series)
569571

570572
results = []

tests/test_integration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
uv run pytest -m integration
2828
"""
2929

30+
from collections.abc import AsyncIterator
31+
3032
import grpc
3133
import pytest
3234
from grpc.aio import AioRpcError
@@ -51,7 +53,7 @@
5153

5254

5355
@pytest.fixture
54-
async def client():
56+
async def client() -> AsyncIterator[MarketMeteringApiClient]:
5557
"""Create a connected client for testing."""
5658
c = MarketMeteringApiClient(
5759
server_url=SERVICE_URL,

0 commit comments

Comments
 (0)