mobilityhouse / ocpp

Python implementation of the Open Charge Point Protocol (OCPP).
MIT License
790 stars 315 forks source link

The serialisation of soc to SoC should not occur in camel case if it is existing at the beginning of a field #523

Closed Jared-Newell-Mobility closed 8 months ago

Jared-Newell-Mobility commented 12 months ago

https://github.com/mobilityhouse/ocpp/blob/7e14b1664588e9f732f21fc5ff08369693385f35/ocpp/charge_point.py#L45-L60

consider this fictional field:

@dataclass
class Bidirectional:
    soc_battery: Optional[str] = None

when serialised;

results in SoCBattery when it should be socBattery

`@dataclass class Bidirectional: soc_battery: Optional[str] = None

def test_serialise():

expected = {'socBattery': None}

assert snake_to_camel_case(asdict(Bidirectional())) == expected`

test_v2x serialisation.py:38 (test_serialise) {'SoCBattery': None} != {'socBattery': None}

Jared-Newell-Mobility commented 8 months ago

Merged so will close