Série: ocpp
python
71 lignes
· Mis à jour 2025-10-10
conftest.py
ocpp/homework/ocpp_many/tests/v201/conftest.py
from unittest.mock import AsyncMock
import pytest
from ocpp.messages import Call, CallResult
from ocpp.v201 import ChargePoint, call
from ocpp.v201.enums import Action
chargingStation = {
"vendorName": "ICU Eve Mini",
"firmwareVersion": "#1:3.4.0-2990#N:217H;1.0-223",
"model": "ICU Eve Mini",
}
@pytest.fixture
def heartbeat_call():
return Call(unique_id=1, action=Action.heartbeat, payload={}).to_json()
@pytest.fixture
def boot_notification_call():
return Call(
unique_id="1",
action=Action.boot_notification,
payload={
"reason": "PowerUp",
"chargingStation": chargingStation,
},
).to_json()
@pytest.fixture
def base_central_system(connection):
cs = ChargePoint(
id=1234,
connection=connection,
)
cs._unique_id_generator = lambda: 1337
return cs
@pytest.fixture
def mock_boot_request():
return call.BootNotification(
reason="PowerUp",
charging_station=chargingStation,
)
@pytest.fixture
def mock_base_central_system(base_central_system):
mock_result_call = CallResult(
unique_id=str(base_central_system._unique_id_generator()),
action=Action.boot_notification,
payload={
"currentTime": "2018-05-29T17:37:05.495259",
"interval": 350,
"status": "Accepted",
},
)
base_central_system._send = AsyncMock()
mock_response = AsyncMock()
mock_response.return_value = mock_result_call
base_central_system._get_specific_response = mock_response
return base_central_system
Articles liés
ocpp
python
Mis à jour 2026-02-03
central_system.py
central_system.py — python source code from the ocpp learning materials (ocpp/homework/central_system.py).
Lire l'article →
ocpp
python
Mis à jour 2026-02-03
charge_point.py
charge_point.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/charge_point.py).
Lire l'article →
ocpp
python
Mis à jour 2026-02-03
exceptions.py
exceptions.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/exceptions.py).
Lire l'article →
ocpp
python
Mis à jour 2026-02-03
messages.py
messages.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/messages.py).
Lire l'article →
ocpp
python
Mis à jour 2026-02-03
routing.py
routing.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/routing.py).
Lire l'article →
ocpp
python
Mis à jour 2026-02-03
__init__.py
__init__.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/v16/__init__.py).
Lire l'article →