Skip to content

Commit

Permalink
Merge branch 'master' into camel_to_snake_case-doesn't-handle-v2x-cor…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
Jared-Newell-Mobility authored Feb 7, 2024
2 parents f57e00f + ea5f8c1 commit 5358ce8
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @OrangeTux @tropxy
* @OrangeTux @tropxy @Jared-Newell-Mobility
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Change log
- [#557](https://github.com/mobilityhouse/ocpp/issues/557) OCPP 2.0.1 Wrong data type in CostUpdated total_cost
- [#564](https://github.com/mobilityhouse/ocpp/issues/564) Add support For Python 3.11 and 3.12
- [#583](https://github.com/mobilityhouse/ocpp/issues/583) OCPP v1.6/v2.0.1 deprecate dataclasses from calls and call results with the suffix 'Payload'
- [#591](https://github.com/mobilityhouse/ocpp/issues/591) Camel_to_snake_case doesn't handle v2x correctly
- [#593](https://github.com/mobilityhouse/ocpp/issues/593) Update tests to use Call and CallResult without the suffix Payload

## 0.26.0 (2024-01-17)

Expand Down
7 changes: 6 additions & 1 deletion ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,14 @@ async def call(self, payload, suppress=True, unique_id=None):
unique_id if unique_id is not None else str(self._unique_id_generator())
)

action_name = payload.__class__.__name__
# Due to deprecated call and callresults, remove in the future.
if "Payload" in payload.__class__.__name__:
action_name = payload.__class__.__name__[:-7]

call = Call(
unique_id=unique_id,
action=payload.__class__.__name__[:-7],
action=action_name,
payload=remove_nones(camel_case_payload),
)

Expand Down
2 changes: 1 addition & 1 deletion ocpp/v201/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ClearedChargingLimit:

@dataclass
class CostUpdated:
total_cost: int
total_cost: float
transaction_id: str
custom_data: Optional[Dict[str, Any]] = None

Expand Down
115 changes: 102 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ classifiers = [
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.7'
]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.7"
jsonschema = "^4.4.0"

[tool.poetry.dev-dependencies]
# Starting from Python 3.8, asynctest is replaced with a unittest.mock.AsyncMock in standard library.
asynctest = { version = "0.13.0", python = "~3.7" }
pytest = "^7"
pytest-asyncio = "^0.20.3"
pytest-cov = "^4.0.0"
Expand Down
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from unittest.mock import AsyncMock
try:
from unittest.mock import AsyncMock
except ImportError:
# Python 3.7 and below don't include unittest.mock.AsyncMock. Hence,
# we need to resolve to a package on pypi.
from asynctest import CoroutineMock as AsyncMock

import pytest

Expand Down
Loading

0 comments on commit 5358ce8

Please sign in to comment.