Skip to content
Merged
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 .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ updates:
- "ty"
test:
patterns:
- "aioresponses"
- "aiointercept"
- "pytest"
- "pytest-*"
- "syrupy"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
pull-request-number: "${{ github.event.pull_request.number }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: >-
breaking-change, bugfix, documentation, enhancement, tests
breaking-change, bugfix, documentation, enhancement, tests,
refactor, performance, new-feature, maintenance, ci, dependencies
disable-reviews: true
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tests/
## Testing

- Run with `pytest` (async tests use `pytest-asyncio`)
- Mock HTTP via `aioresponses`; do not hit real endpoints in tests
- Mock HTTP via `aiointercept`; do not hit real endpoints in tests
- Snapshots use `syrupy` (`tests/snapshots/`) — update with `pytest --snapshot-update` when output structures change
- Update both snapshots and fixtures together when response shapes change

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
]
requires-python = ">=3.13"
dependencies = [
"aiohttp>=3.13.4",
"aiohttp>=3.14.1",
"dacite>=1.7.0",
"yarl",
]
Expand All @@ -30,10 +30,10 @@ dependencies = [
dev = [
"prek==0.4.4",
"ruff==0.15.17",
"ty==0.0.49",
"ty==0.0.50",
]
test = [
"aioresponses==0.7.8",
"aiointercept==0.1.7",
"pytest-asyncio==1.4.0",
"pytest-cov==7.1.0",
"pytest-error-for-skips==2.0.2",
Expand Down
16 changes: 8 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
"""Set up some common test helper things."""

import json
from collections.abc import AsyncGenerator, Generator
from collections.abc import AsyncGenerator
from pathlib import Path
from typing import Any

import aiohttp
import pytest
import pytest_asyncio
from aioresponses import aioresponses
from aiointercept import aiointercept
from syrupy.assertion import SnapshotAssertion
from syrupy.extensions.amber import AmberSnapshotExtension
from syrupy.location import PyTestLocation

BASE = "tests/fixtures/"


@pytest_asyncio.fixture
async def session() -> AsyncGenerator[aiohttp.ClientSession]:
@pytest_asyncio.fixture(loop_scope="function")
async def session(session_mock: aiointercept) -> AsyncGenerator[aiohttp.ClientSession]: # noqa: ARG001
"""Return a mock ClientSession."""
session = aiohttp.ClientSession()
yield session
await session.close()


@pytest.fixture
def session_mock() -> Generator[aioresponses]:
"""Create a reusable aioresponses mock."""
with aioresponses() as mock:
@pytest_asyncio.fixture(loop_scope="function")
async def session_mock() -> AsyncGenerator[aiointercept]:
"""Create a reusable aiointercept mock."""
async with aiointercept(mock_external_urls=True) as mock:
yield mock


Expand Down
26 changes: 13 additions & 13 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import aiohttp
import pytest
from aioresponses import aioresponses
from aiointercept import aiointercept
from syrupy import SnapshotAssertion

from gios import ApiError, Gios, InvalidSensorsDataError, NoStationError
Expand All @@ -21,7 +21,7 @@
@pytest.mark.asyncio
async def test_init_only(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
snapshot: SnapshotAssertion,
stations: dict[str, Any],
) -> None:
Expand All @@ -46,7 +46,7 @@ async def test_init_only(
@pytest.mark.asyncio
async def test_valid_data_first_value(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
snapshot: SnapshotAssertion,
stations: dict[str, Any],
station: list[dict[str, Any]],
Expand Down Expand Up @@ -115,7 +115,7 @@ async def test_valid_data_first_value(

@pytest.mark.asyncio
async def test_api_error(
session: aiohttp.ClientSession, session_mock: aioresponses
session: aiohttp.ClientSession, session_mock: aiointercept
) -> None:
"""Test GIOS API error."""
session_mock.get(
Expand All @@ -132,7 +132,7 @@ async def test_api_error(
@pytest.mark.asyncio
async def test_valid_data_second_value(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
snapshot: SnapshotAssertion,
stations: dict[str, Any],
station: list[dict[str, Any]],
Expand Down Expand Up @@ -207,7 +207,7 @@ async def test_valid_data_second_value(
@pytest.mark.asyncio
async def test_no_indexes_data(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
snapshot: SnapshotAssertion,
stations: dict[str, Any],
station: list[dict[str, Any]],
Expand Down Expand Up @@ -276,7 +276,7 @@ async def test_no_indexes_data(
@pytest.mark.asyncio
async def test_no_sensor_data_1(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
station: list[dict[str, Any]],
indexes: dict[str, Any],
Expand Down Expand Up @@ -354,7 +354,7 @@ async def test_no_sensor_data_1(
@pytest.mark.asyncio
async def test_invalid_sensor_data_2(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
station: list[dict[str, Any]],
) -> None:
Expand Down Expand Up @@ -406,7 +406,7 @@ async def test_invalid_sensor_data_2(
@pytest.mark.asyncio
async def test_no_station_data(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
) -> None:
"""Test with no station data."""
Expand All @@ -429,7 +429,7 @@ async def test_no_station_data(

@pytest.mark.asyncio
async def test_no_stations_data(
session: aiohttp.ClientSession, session_mock: aioresponses
session: aiohttp.ClientSession, session_mock: aiointercept
) -> None:
"""Test with no stations data."""
session_mock.get(
Expand All @@ -444,7 +444,7 @@ async def test_no_stations_data(
@pytest.mark.asyncio
async def test_invalid_station_id(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
) -> None:
"""Test with invalid station_id."""
Expand All @@ -460,7 +460,7 @@ async def test_invalid_station_id(
@pytest.mark.asyncio
async def test_no_common_index(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
station: list[dict[str, Any]],
indexes: dict[str, Any],
Expand Down Expand Up @@ -527,7 +527,7 @@ async def test_no_common_index(
@pytest.mark.asyncio
async def test_multiple_pages(
session: aiohttp.ClientSession,
session_mock: aioresponses,
session_mock: aiointercept,
stations: dict[str, Any],
) -> None:
"""Test that all pages are fetched when totalPages > 1."""
Expand Down
Loading