Skip to content

chore: Add integration and unit tests for Python and .NET SDKs#132

Draft
joakimia wants to merge 4 commits into
mainfrom
chore/add-integration-tests
Draft

chore: Add integration and unit tests for Python and .NET SDKs#132
joakimia wants to merge 4 commits into
mainfrom
chore/add-integration-tests

Conversation

@joakimia

@joakimia joakimia commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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 WhenHandlingTransientErrors test 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.py

Method Type Description
get_currents Historical Current measurements for a line over a time range
get_conductor_temperatures Historical Conductor temperature measurements for a line
get_icing Historical Icing measurements for a line over a time range
get_sag_and_clearance Historical Sag and clearance measurements for a line
get_apparent_power Historical Apparent power measurements for a line
get_latest_apparent_power Latest Most recent apparent power measurement
get_icing_forecast Forecast Latest icing forecast for a line

capacity_monitoring.py / client.py

Method Type Description
get_heimdall_dlrs Historical Heimdall DLR values for a line over a time range
get_heimdall_aars Historical Heimdall AAR values for a line over a time range
get_circuit_ratings Historical Circuit ratings for a facility over a time range

Tests

Tests are split by stability:

  • Integration tests — only cover historical endpoints where the response is deterministic for a fixed time range. Tests run against the real API using the Heimdall Power Line (d67d2205-…) test fixture.
  • Unit tests — cover all latest and forecast endpoints using mocks, since these can return 404 when no recent data exists. Each endpoint is tested for:
    1. 200 OK → parsed response is returned
    2. 404 Not FoundHeimdallApiError(status_code=404) is raised
    3. 404 is not retried → time.sleep is never called

New test files:

File Type Coverage
tests/integration/test_when_fetching_capacity_monitoring.py Integration get_heimdall_dlrs, get_heimdall_aars, get_circuit_ratings + invalid-ID error paths
tests/integration/test_when_fetching_grid_insights.py Integration get_currents, get_conductor_temperatures, get_icing, get_sag_and_clearance, get_apparent_power + invalid-ID error path
tests/unit/test_latest_endpoints.py Unit All 12 latest/forecast methods on HeimdallApiClient — 200 OK, 404 raised, 404 not retried
tests/unit/test_auth_service.py Unit Token caching, expiry, region extraction

.NET SDK

Test fakes for WhenHandlingTransientErrors

Added fake infrastructure under WhenHandlingTransientErrors/Fakes/ to support unit testing of the HeimdallApiHttpClient when transient errors occur:

File Description
FakeHttpMessageHandler.cs Returns a fixed response or a sequence of responses, mirroring the one in WhenHandlingErrorResponses
HeimdallApiHttpClientFactory.cs Factory that wires up HeimdallApiHttpClient with the fake handler and a no-op delay for instant tests
StubAccessTokenProvider.cs Stub IAccessTokenProvider returning a static token

These follow the same pattern as the existing WhenHandlingErrorResponses/Fakes/ test infrastructure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant