chore: Add integration and unit tests for Python and .NET SDKs - #132
Closed
joakimia wants to merge 4 commits into
Closed
chore: Add integration and unit tests for Python and .NET SDKs#132joakimia wants to merge 4 commits into
joakimia wants to merge 4 commits into
Conversation
joakimia
force-pushed
the
chore/add-integration-tests
branch
from
July 22, 2026 10:34
1a5ec33 to
fae1c21
Compare
joakimia
marked this pull request as ready for review
July 22, 2026 10:38
6 tasks
mHjertaker
added a commit
that referenced
this pull request
Aug 5, 2026
## Summary Extracted from #132. Wires grid_insights and capacity_monitoring endpoints that already existed in the generated API clients through `HeimdallApiClient`, and fixes what surfaced when those wrappers were first exercised against the API. **New endpoint wrappers** - Historical: `get_currents`, `get_conductor_temperatures`, `get_icing`, `get_sag_and_clearance`, `get_apparent_power`, `get_heimdall_dlrs`, `get_heimdall_aars`, `get_circuit_ratings` - Latest: `get_latest_apparent_power`, `get_icing_forecast` **Fixes** - `get_currents` raised `ImportError` at call time — the client method imported a wrapper that was never written. The import is function-local, so linting and package import stayed green. - Windowed endpoints returned 400: timestamps must be Z-suffixed UTC, but `datetime.isoformat()` always emits a `+00:00` offset. Normalized via `as_zulu()` in `_timestamps.py`, applied in the hand-written wrappers so regeneration cannot overwrite it. Naive input is treated as UTC; other offsets are converted. - Forwarded parameters the wrappers dropped: `unit_system` on `get_conductor_temperatures`, `quantity` on the three rating endpoints, and `since` on the latest endpoints that accept it. **Generator** `openapi-python-client` formats its output via post-hooks that call the bare `ruff` executable, which silently no-ops when ruff is not on `PATH` — leaving generated code unformatted and turning a 3-file change into a 54-file diff. The hooks now run through `python -m ruff`, and unformatted output fails `generate-module-client.ps1` rather than reaching a commit. Both modules are regenerated with that in place. **Tests** - `tests/integration/` — windowed and latest endpoints in separate files, covering `unit_system`, `quantity`, `since`, timestamp normalization across naive / UTC / offset input, and the 30-day window cap. Endpoints skip rather than fail on 404 so an asset without data for a metric cannot mask a wiring bug. - `tests/unit/` — resolves every lazily-imported wrapper and covers `as_zulu`. These run on pull requests, where the integration suite does not. --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Marius Hjertaker <marius.hjertaker@heimdallpower.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expands the Python SDK with missing endpoint wrappers, introduces a full integration- and unit-test suite covering all Python endpoints, and adds test fake infrastructure for the .NET
WhenHandlingTransientErrorstest suite.Python SDK
New endpoint wrappers
The following endpoints existed in the generated API client but were not exposed through the SDK wrapper or
HeimdallApiClient. They are now fully implemented:grid_insights.py/client.pyget_currentsget_conductor_temperaturesget_icingget_sag_and_clearanceget_apparent_powerget_latest_apparent_powerget_icing_forecastcapacity_monitoring.py/client.pyget_heimdall_dlrsget_heimdall_aarsget_circuit_ratingsTests
Tests are split by stability:
Heimdall Power Line(d67d2205-…) test fixture.latestandforecastendpoints using mocks, since these can return404when no recent data exists. Each endpoint is tested for:200 OK→ parsed response is returned404 Not Found→HeimdallApiError(status_code=404)is raised404is not retried →time.sleepis never calledNew test files:
tests/integration/test_when_fetching_capacity_monitoring.pyget_heimdall_dlrs,get_heimdall_aars,get_circuit_ratings+ invalid-ID error pathstests/integration/test_when_fetching_grid_insights.pyget_currents,get_conductor_temperatures,get_icing,get_sag_and_clearance,get_apparent_power+ invalid-ID error pathtests/unit/test_latest_endpoints.pylatest/forecastmethods onHeimdallApiClient— 200 OK, 404 raised, 404 not retriedtests/unit/test_auth_service.py.NET SDK
Test fakes for
WhenHandlingTransientErrorsAdded fake infrastructure under
WhenHandlingTransientErrors/Fakes/to support unit testing of theHeimdallApiHttpClientwhen transient errors occur:FakeHttpMessageHandler.csWhenHandlingErrorResponsesHeimdallApiHttpClientFactory.csHeimdallApiHttpClientwith the fake handler and a no-op delay for instant testsStubAccessTokenProvider.csIAccessTokenProviderreturning a static tokenThese follow the same pattern as the existing
WhenHandlingErrorResponses/Fakes/test infrastructure.