Series: ocpp
python
41 lines
· Updated 2025-10-10
test_routing.py
ocpp/homework/ocpp_many/tests/test_routing.py
from ocpp.routing import after, create_route_map, on
from ocpp.v16.enums import Action
def test_create_route_map():
"""
This test validates that route map is created correctly and holds all
functions decorated with the @on() and @after decorators.
"""
class ChargePoint:
@on(Action.heartbeat, skip_schema_validation=True)
def on_heartbeat(self):
pass
@after(Action.heartbeat)
def after_heartbeat(self):
pass
@on(Action.meter_values)
def meter_values(self):
pass
def undecorated(self):
pass
cp = ChargePoint()
route_map = create_route_map(cp)
assert route_map == {
Action.heartbeat: {
"_on_action": cp.on_heartbeat,
"_after_action": cp.after_heartbeat,
"_skip_schema_validation": True,
},
Action.meter_values: {
"_on_action": cp.meter_values,
"_skip_schema_validation": False,
},
}
Related articles
ocpp
python
Updated 2026-02-03
central_system.py
central_system.py — python source code from the ocpp learning materials (ocpp/homework/central_system.py).
Read article →
ocpp
python
Updated 2026-02-03
charge_point.py
charge_point.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/charge_point.py).
Read article →
ocpp
python
Updated 2026-02-03
exceptions.py
exceptions.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/exceptions.py).
Read article →
ocpp
python
Updated 2026-02-03
messages.py
messages.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/messages.py).
Read article →
ocpp
python
Updated 2026-02-03
routing.py
routing.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/routing.py).
Read article →
ocpp
python
Updated 2026-02-03
__init__.py
__init__.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/v16/__init__.py).
Read article →