Skip to content

15 test for ocpp session#23

Open
snabo1988 wants to merge 3 commits intomainfrom
15-test-for-OCPP-session
Open

15 test for ocpp session#23
snabo1988 wants to merge 3 commits intomainfrom
15-test-for-OCPP-session

Conversation

@snabo1988
Copy link
Copy Markdown
Contributor

This PR introduces initial automated test coverage for the OCPP session listing
and failure-detection flow, aligned with the current MVP scope.

During implementation, the tests exposed a real architectural issue:
duplicated response schemas and an inconsistent response shape for /api/v1/sessions.
This has been unified as part of the work, improving API consistency and correctness.

The current test set is considered sufficient for MVP:

  • authentication enforcement on /api/v1/sessions
  • basic faulted-session persistence and retrieval
  • response model validation

Additional test scenarios are intentionally deferred and will be handled
in follow-up issues once the session lifecycle logic is extended, including:

  • silent failure detection (Preparing → Available without Charging)
  • pagination and ordering edge cases
  • mixed session state handling
  • extended error-code coverage

Architectural rationale and scope decisions are documented in ADR-001.

@snabo1988 snabo1988 requested a review from knowack1 January 30, 2026 23:16
@router.get(
"/sessions",
response_model=FaultedSessionsResponse,
dependencies=[Depends(require_scopes({"sessions:read"}))],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is suppose to be about tests but introduces something related to authorization - please cleanup.

→ must return 200
"""
headers = {
"Authorization": "Bearer dev-secret-key"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not authorization: anyone get provide such header. The string in the bearer should be digital signed. Read and apply JSON Web Token (JWT)

charge_point_id="CP-TEST-001",
connector_id=1,
error_code="GroundFailure",
timestamp=datetime.now(UTC), # ← TU JEST KLUCZ
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment in PL?



def insert_faulted_session(db):
session = db.insert_session(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should connect to the server as a charger - OCPP.




def test_faulted_session_is_returned(client, db):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should focus only on this test. Other tests should be removed for now.

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.

2 participants