Skip to content

Add automated tests for OCPP session failure detection #15

@snabo1988

Description

@snabo1988

Goal

Introduce automated tests to validate OCPP session lifecycle handling,
with a focus on failed and silent-failed sessions.

Manual testing is no longer sufficient as session logic becomes more complex.


Related Issues


Scope

Tests should cover OCPP 1.6 StatusNotification flows related to session
creation, failure detection, and cleanup.


Required Test Scenarios

1. Silent failure detection (Issue #8)

Given
Available → Preparing → Available

Then

  • Session is classified as failed
  • handle_failed_session() is called
  • Failure reason:
    PREPARING_ABORTED_BEFORE_CHARGING

2. Valid charging session (negative test)

Given
Available → Preparing → Charging → Available

Then

  • Session is NOT classified as failed
  • handle_failed_session() is NOT called

3. Faulted session (regression test)

Given
Preparing → Faulted

Then

  • Existing fault handling logic remains unchanged

4. Session cleanup

  • Session state is removed after Available or Faulted
  • No leaks in internal session storage

Implementation Notes

  • Use pytest
  • No real EVSE or network access
  • Mock Engine and FTP dependencies
  • Prefer direct async calls to handle_status_notification()

Acceptance Criteria

  • All scenarios covered by automated tests
  • Tests fail if silent failure detection breaks
  • Tests runnable via: pytest

Metadata

Metadata

Assignees

Labels

mvpMVP scopequalityCode quality and test coveragetestsAutomated tests

Type

No type

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions