From 1fcc49d51185282bba9b7362b6beef302f109770 Mon Sep 17 00:00:00 2001 From: Jared-Newell-Mobility <119603687+Jared-Newell-Mobility@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:31:38 +0100 Subject: [PATCH 1/4] Update Code Owners (#588) see issue https://github.com/mobilityhouse/ocpp/issues/587 --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ff8ee0574..9cd57fd8f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @OrangeTux @tropxy +* @OrangeTux @tropxy @Jared-Newell-Mobility From 3963e7a5b46c2c2a5598dbcda57b8cc13a3efe14 Mon Sep 17 00:00:00 2001 From: Jared-Newell-Mobility <119603687+Jared-Newell-Mobility@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:34:09 +0100 Subject: [PATCH 2/4] Revert "drop support for python 3.7" (#597) Reverts mobilityhouse/ocpp#585 As this is breaking should be included in release 1.0.0 --- .github/workflows/pull-request.yml | 1 + poetry.lock | 115 +++++++++++++++++++++++++---- pyproject.toml | 4 +- tests/conftest.py | 7 +- tests/v16/conftest.py | 7 +- tests/v201/conftest.py | 7 +- 6 files changed, 124 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 52a5985de..e37b46c43 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: version: + - "3.7" - "3.8" - "3.9" - "3.10" diff --git a/poetry.lock b/poetry.lock index 34926ea37..b11664c88 100644 --- a/poetry.lock +++ b/poetry.lock @@ -12,6 +12,18 @@ files = [ {file = "alabaster-0.7.13.tar.gz", hash = "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2"}, ] +[[package]] +name = "asynctest" +version = "0.13.0" +description = "Enhance the standard unittest package with features for testing asyncio libraries" +category = "dev" +optional = false +python-versions = ">=3.5" +files = [ + {file = "asynctest-0.13.0-py3-none-any.whl", hash = "sha256:5da6118a7e6d6b54d83a8f7197769d046922a44d2a99c21382f0a6e4fadae676"}, + {file = "asynctest-0.13.0.tar.gz", hash = "sha256:c27862842d15d83e6a34eb0b2866c323880eb3a75e4485b079ea11748fd77fac"}, +] + [[package]] name = "attrs" version = "23.2.0" @@ -24,6 +36,9 @@ files = [ {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, ] +[package.dependencies] +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} + [package.extras] cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] dev = ["attrs[tests]", "pre-commit"] @@ -78,6 +93,7 @@ mypy-extensions = ">=0.4.3" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} +typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} [package.extras] @@ -212,6 +228,7 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -341,6 +358,7 @@ files = [ ] [package.dependencies] +importlib-metadata = {version = ">=1.1.0,<4.3", markers = "python_version < \"3.8\""} mccabe = ">=0.7.0,<0.8.0" pycodestyle = ">=2.9.0,<2.10.0" pyflakes = ">=2.5.0,<2.6.0" @@ -369,6 +387,26 @@ files = [ {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, ] +[[package]] +name = "importlib-metadata" +version = "4.2.0" +description = "Read metadata from Python packages" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ + {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, + {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, +] + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] + [[package]] name = "importlib-resources" version = "5.12.0" @@ -450,9 +488,11 @@ files = [ [package.dependencies] attrs = ">=17.4.0" +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""} pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] @@ -486,16 +526,6 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -600,6 +630,9 @@ files = [ {file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"}, ] +[package.dependencies] +typing-extensions = {version = ">=4.7.1", markers = "python_version < \"3.8\""} + [package.extras] docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] @@ -616,6 +649,9 @@ files = [ {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, ] +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] @@ -712,6 +748,7 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" @@ -734,6 +771,7 @@ files = [ [package.dependencies] pytest = ">=6.1.0" +typing-extensions = {version = ">=3.7.2", markers = "python_version < \"3.8\""} [package.extras] docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] @@ -963,11 +1001,62 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "typed-ast" +version = "1.5.5" +description = "a fork of Python 2 and 3 ast modules with type comment support" +category = "dev" +optional = false +python-versions = ">=3.6" +files = [ + {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"}, + {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"}, + {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"}, + {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"}, + {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"}, + {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"}, + {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"}, + {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"}, + {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"}, + {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"}, + {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"}, +] + [[package]] name = "typing-extensions" version = "4.7.1" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "dev" +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1011,5 +1100,5 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "ff5acd04841119c203edb825e4905c233389b9168d15fe345611757b93c11af9" +python-versions = "^3.7" +content-hash = "21d1add46de6767e4784710ad659f8881d8eeaf99e0c60b3e1e80d0201600194" diff --git a/pyproject.toml b/pyproject.toml index 704249463..92d56c745 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tests/conftest.py b/tests/conftest.py index 51c17e22b..69e0561c0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/v16/conftest.py b/tests/v16/conftest.py index 67dea686f..a8dfc365f 100644 --- a/tests/v16/conftest.py +++ b/tests/v16/conftest.py @@ -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 diff --git a/tests/v201/conftest.py b/tests/v201/conftest.py index 97dd2b9dd..ca71fc5b3 100644 --- a/tests/v201/conftest.py +++ b/tests/v201/conftest.py @@ -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 From c4d96d9e876d630fee80153a8ef3c3ddaed8d8dd Mon Sep 17 00:00:00 2001 From: Jared-Newell-Mobility <119603687+Jared-Newell-Mobility@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:51:26 +0100 Subject: [PATCH 3/4] OCPP 2.0.1 Wrong data type in CostUpdated total_cost (#596) see issue https://github.com/mobilityhouse/ocpp/issues/557 --- CHANGELOG.md | 1 + ocpp/v201/call.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 149f2876b..4a476590a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # 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' diff --git a/ocpp/v201/call.py b/ocpp/v201/call.py index 461f37365..ddc681606 100644 --- a/ocpp/v201/call.py +++ b/ocpp/v201/call.py @@ -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 From ea5f8c1451f5d15907b40dba8efc7cba16a48d74 Mon Sep 17 00:00:00 2001 From: Jared-Newell-Mobility <119603687+Jared-Newell-Mobility@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:54:34 +0100 Subject: [PATCH 4/4] Update tests to use Call and CallResult without the suffix Payload (#595) See issue https://github.com/mobilityhouse/ocpp/issues/593 --- CHANGELOG.md | 1 + ocpp/charge_point.py | 7 ++++++- tests/test_charge_point.py | 30 ++++++++++------------------ tests/v16/conftest.py | 2 +- tests/v16/test_v16_charge_point.py | 14 ++++++------- tests/v201/conftest.py | 2 +- tests/v201/test_v201_charge_point.py | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a476590a..a56837bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - [#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' +- [#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) diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 4d7cb9676..0e9337558 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -311,9 +311,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), ) diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index 897fabc2b..cefcb1860 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -6,18 +6,12 @@ from ocpp.messages import Call from ocpp.routing import after, create_route_map, on from ocpp.v16 import ChargePoint as cp_16 -from ocpp.v16.call import ( - BootNotificationPayload, - GetConfigurationPayload, - MeterValuesPayload, -) -from ocpp.v16.call_result import ( - BootNotificationPayload as BootNotificationResultPayload, -) +from ocpp.v16.call import BootNotification, GetConfiguration, MeterValues +from ocpp.v16.call_result import BootNotification as BootNotificationResult from ocpp.v16.datatypes import MeterValue, SampledValue from ocpp.v16.enums import Action, RegistrationStatus from ocpp.v20 import ChargePoint as cp_20 -from ocpp.v201.call import SetNetworkProfilePayload +from ocpp.v201.call import SetNetworkProfile from ocpp.v201.datatypes import NetworkConnectionProfileType from ocpp.v201.enums import OCPPInterfaceType, OCPPTransportType, OCPPVersionType @@ -82,7 +76,7 @@ def test_snake_to_camel_case(test_input, expected): def test_remove_nones(): expected_payload = {"charge_point_model": "foo", "charge_point_vendor": "bar"} - payload = BootNotificationPayload( + payload = BootNotification( charge_point_model="foo", charge_point_vendor="bar", charge_box_serial_number=None, @@ -116,9 +110,7 @@ def test_nested_remove_nones(): apn=None, ) - payload = SetNetworkProfilePayload( - configuration_slot=1, connection_data=connection_data - ) + payload = SetNetworkProfile(configuration_slot=1, connection_data=connection_data) payload = asdict(payload) assert expected_payload == remove_nones(payload) @@ -168,7 +160,7 @@ def test_nested_list_remove_nones(): "transaction_id": 5, } - payload = MeterValuesPayload( + payload = MeterValues( connector_id=3, meter_value=[ MeterValue( @@ -231,7 +223,7 @@ def test_remove_nones_with_list_of_strings(): https://github.com/mobilityhouse/ocpp/issues/289. """ payload = asdict( - GetConfigurationPayload(key=["ClockAlignedDataInterval", "ConnectionTimeOut"]) + GetConfiguration(key=["ClockAlignedDataInterval", "ConnectionTimeOut"]) ) assert remove_nones(payload) == { @@ -274,7 +266,7 @@ def on_boot_notification(self, *args, **kwargs): assert kwargs == camel_to_snake_case(payload_a) assert args == () ChargerA.on_boot_notification_call_count += 1 - return BootNotificationResultPayload( + return BootNotificationResult( current_time="foo", interval=1, status=RegistrationStatus.accepted ) @@ -285,7 +277,7 @@ def after_boot_notification(self, call_unique_id, *args, **kwargs): # call_unique_id should not be passed as arg assert args == () ChargerA.after_boot_notification_call_count += 1 - return BootNotificationResultPayload( + return BootNotificationResult( current_time="foo", interval=1, status=RegistrationStatus.accepted ) @@ -300,7 +292,7 @@ def on_boot_notification(self, call_unique_id, *args, **kwargs): # call_unique_id should not be passed as arg assert args == () ChargerB.on_boot_notification_call_count += 1 - return BootNotificationResultPayload( + return BootNotificationResult( current_time="foo", interval=1, status=RegistrationStatus.accepted ) @@ -310,7 +302,7 @@ def after_boot_notification(self, *args, **kwargs): assert kwargs == camel_to_snake_case(payload_b) assert args == () ChargerB.after_boot_notification_call_count += 1 - return BootNotificationResultPayload( + return BootNotificationResult( current_time="foo", interval=1, status=RegistrationStatus.accepted ) diff --git a/tests/v16/conftest.py b/tests/v16/conftest.py index a8dfc365f..b70711ce3 100644 --- a/tests/v16/conftest.py +++ b/tests/v16/conftest.py @@ -49,7 +49,7 @@ def base_central_system(connection): @pytest.fixture def mock_boot_request(): - return call.BootNotificationPayload( + return call.BootNotification( charge_point_vendor="dummy_vendor", charge_point_model="dummy_model", ) diff --git a/tests/v16/test_v16_charge_point.py b/tests/v16/test_v16_charge_point.py index 9d07acf23..37d8d8e3c 100644 --- a/tests/v16/test_v16_charge_point.py +++ b/tests/v16/test_v16_charge_point.py @@ -26,7 +26,7 @@ def on_boot_notification(charge_point_model, charge_point_vendor, **kwargs): # assert charge_point_model == "ICU Eve Mini" assert kwargs["firmware_version"] == "#1:3.4.0-2990#N:217H;1.0-223" - return call_result.BootNotificationPayload( + return call_result.BootNotification( current_time="2018-05-29T17:37:05.495259", interval=350, status="Accepted", @@ -66,7 +66,7 @@ async def test_route_message_without_validation(base_central_system): def on_boot_notification(**kwargs): # noqa assert kwargs["firmware_version"] == "#1:3.4.0-2990#N:217H;1.0-223" - return call_result.BootNotificationPayload( + return call_result.BootNotification( current_time="2018-05-29T17:37:05.495259", interval=350, # 'Yolo' is not a valid value for for field status. @@ -120,7 +120,7 @@ async def test_route_message_not_supported(base_central_system, not_supported_ca def on_boot_notification(**kwargs): # noqa assert kwargs["firmware_version"] == "#1:3.4.0-2990#N:217H;1.0-223" - return call_result.BootNotificationPayload( + return call_result.BootNotification( current_time="2018-05-29T17:37:05.495259", interval=350, # 'Yolo' is not a valid value for for field status. @@ -174,7 +174,7 @@ async def test_route_message_with_no_route(base_central_system, heartbeat_call): async def test_send_call_with_timeout(connection): cs = ChargePoint(id=1234, connection=connection, response_timeout=0.1) - payload = call.ResetPayload(type="Hard") + payload = call.Reset(type="Hard") with pytest.raises(asyncio.TimeoutError): await cs.call(payload) @@ -187,7 +187,7 @@ async def test_send_call_with_timeout(connection): @pytest.mark.asyncio async def test_send_invalid_call(base_central_system): - payload = call.ResetPayload(type="Medium") + payload = call.Reset(type="Medium") with pytest.raises(FormatViolationError): await base_central_system.call(payload) @@ -207,7 +207,7 @@ async def test_raise_call_error(base_central_system): ) await base_central_system.route_message(call_error.to_json()) - payload = call.ClearCachePayload() + payload = call.ClearCache() with pytest.raises(GenericError): await base_central_system.call(payload, suppress=False) @@ -226,7 +226,7 @@ async def test_suppress_call_error(base_central_system): ) await base_central_system.route_message(call_error.to_json()) - payload = call.ClearCachePayload() + payload = call.ClearCache() await base_central_system.call(payload) diff --git a/tests/v201/conftest.py b/tests/v201/conftest.py index ca71fc5b3..42fc4ae86 100644 --- a/tests/v201/conftest.py +++ b/tests/v201/conftest.py @@ -48,7 +48,7 @@ def base_central_system(connection): @pytest.fixture def mock_boot_request(): - return call.BootNotificationPayload( + return call.BootNotification( reason="PowerUp", charging_station=chargingStation, ) diff --git a/tests/v201/test_v201_charge_point.py b/tests/v201/test_v201_charge_point.py index ddbd33808..ba32e7f24 100644 --- a/tests/v201/test_v201_charge_point.py +++ b/tests/v201/test_v201_charge_point.py @@ -24,7 +24,7 @@ def on_boot_notification(reason, charging_station, **kwargs): "model": "ICU Eve Mini", } - return call_result.BootNotificationPayload( + return call_result.BootNotification( current_time="2018-05-29T17:37:05.495259", interval=350, status="Accepted",