Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test covering all v2.0.1 datatypes and enums #684

Closed
wants to merge 8 commits into from

Conversation

ajmirsky
Copy link
Contributor

@ajmirsky ajmirsky commented Nov 26, 2024

Changes included in this PR

Adding unit test for all of the v2.0.1 datatypes, so that if any changes -- namely nested models -- are done, there are no regressions in functionality.

Impact

Two enum types were changed to eliminate confusion with their datatype counterparts:

  • IdTokenType is now IdTokenEnumType (matches its name in the json schema)
  • UnitOfMeasureType is now StandardizedUnitsOfMeasureType (matches the name from OCPP 2.0 Appendix 2)

To not cause any breaking changes, IdTokenType and UnitOfMeasureType are aliased to their new counterparts, with a warning message added upon access of their enum members. This method was used as enums can't be subclassed with a __post_init__ method as are some of the datatypes in v1.6.

Checklist

Existing tests pass (with no changes needed). Adding test coverage with no change in functionality

@ajmirsky ajmirsky changed the title V201 datatypes test Unit test covering all v2.0.1 datatypes and enums Nov 26, 2024
@ajmirsky ajmirsky force-pushed the v201_datatypes_test branch 2 times, most recently from ea02518 to e53d73c Compare November 26, 2024 15:16
SECURITY.md Outdated
| Version | Supported |
|----------| ------------------ |
| 2.0.0 | :white_check_mark: |
| 0.26.0 | :white_check_mark: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No version 1.x.x has been released?

Copy link
Contributor Author

@ajmirsky ajmirsky Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite yet : (

there's a release candidate pending since february: https://github.com/mobilityhouse/ocpp/releases

probably should remove 2.0.0 from this list too, until we have a release candidate for that one too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for the confusion, i removed these files as they are really part of #681

CONTRIBUTING.md Outdated
1. [Fork][fork] and clone the repository.
1. Create a new branch: `git checkout -b my-branch-name`.
1. Configure and install the dependencies: `poetry install`.
1. Make sure the tests pass on your machine: `make install & make tests`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A migration to task should be considered. make is not really a build tool the python community use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would agree... sort of. make is so ubiquitous; I've seen many (legitimate) uses of make and python.

for the time being with this PR, was trying to document current process : )

if you think it's important, i could get behind it. could you create an issue ticket so that the community can have the discussion about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for the confusion, i removed these files as they are really part of #681

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerome-benoit which task library were you referring to? there's pytask. but also snakemake, scons, invoke, bitbake all of which are python friendly, although probably way more functionality than is needed here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskpy. The Makefile is only used here to run ordered shell command(s), so is pointless. taskpy can do the same without requiring another external tool.

CONTRIBUTING.md Outdated
1. Make your change, add tests, and make sure the tests still pass.
1. Push to your fork and [submit a pull request][pr] and complete the information in the pull request template.

## Linting requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A migration to ruff should be considered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not as familiar with ruff as black, isort and flake8. could you open an issue and give some justification? i'd be happy to switch over if there's enough support from the community.

apologies for the confusion, i removed these files as they are really part of #681. could you add addition comments there?

@@ -1364,6 +1387,11 @@ class UnitOfMeasureType(StrEnum):
k = "K"


UnitOfMeasureType = DeprecatedEnumWrapper(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it worth the effort. Have these enums been part of any stable release.
Considering rc versions as API stable is unusual.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm mixed on this one.

correct, there has been no official stable release.

But... since 0.26.0 has been in the wild for the past year, there are definitely people who are using/depending on the library

I leaned towards usability for the community in this case but I could be convinced otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerome-benoit actually, given that these OCPP 2.0 files are included in this library's 1.0 release (on pypi), I think it's better to be safe. I don't think the project has made it clear if the library's release version is tied to the OCPP version or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library version is totally independent from the OCPP version supported.

@@ -454,7 +454,7 @@ class IdTokenType:
"""

id_token: str
type: enums.IdTokenType
type: enums.IdTokenEnumType
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's the value add of renaming enums

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compliance with the OCPP specs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross Checked this. This makes me question the whether the rest of the enums and datatypes are compliant or not. Will take a look at this soon.

Copy link
Contributor Author

@ajmirsky ajmirsky Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a double check when I came across this one and all of the others seemed compliant. But another set of eyes is always appreciated!

@ajmirsky ajmirsky mentioned this pull request Dec 8, 2024
@ajmirsky
Copy link
Contributor Author

closing out in favor of the tests in #684

@ajmirsky ajmirsky closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants