-
Notifications
You must be signed in to change notification settings - Fork 326
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
Changes from all commits
68e048b
ef88e26
efbf7b1
ef2907a
e53d73c
051aa93
26b35b8
1d51685
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,26 @@ class StrEnum(str, Enum): # pragma: no cover | |
pass # pragma: no cover | ||
|
||
|
||
class DeprecatedEnumWrapper: | ||
""" | ||
Since enums can't be subclassed in order to add a deprecation warning, | ||
this class is included to help warn users of deprecated enums. | ||
""" | ||
|
||
def __init__(self, enum_class, alias_name): | ||
self.enum_class = enum_class | ||
self.alias_name = alias_name | ||
|
||
def __getattr__(self, name): | ||
warn( | ||
( | ||
f"Enum '{self.alias_name}' is deprecated, " | ||
+ "instead use '{self.enum_class.__name__}'" | ||
) | ||
) | ||
return getattr(self.enum_class, name) | ||
|
||
|
||
class Action(StrEnum): | ||
"""An Action is a required part of a Call message.""" | ||
|
||
|
@@ -721,7 +741,7 @@ class HashAlgorithmType(StrEnum): | |
sha512 = "SHA512" | ||
|
||
|
||
class IdTokenType(StrEnum): | ||
class IdTokenEnumType(StrEnum): | ||
""" | ||
Allowable values of the IdTokenType field. | ||
""" | ||
|
@@ -736,6 +756,9 @@ class IdTokenType(StrEnum): | |
no_authorization = "NoAuthorization" | ||
|
||
|
||
IdTokenType = DeprecatedEnumWrapper(IdTokenEnumType, "IdTokenType") | ||
|
||
|
||
class InstallCertificateStatusType(StrEnum): | ||
""" | ||
InstallCertificateStatusEnumType is used by | ||
|
@@ -1321,7 +1344,7 @@ class VPNType(StrEnum): | |
# DataTypes | ||
|
||
|
||
class UnitOfMeasureType(StrEnum): | ||
class StandardizedUnitsOfMeasureType(StrEnum): | ||
""" | ||
Allowable values of the optional "unit" field of a Value element, as used | ||
in MeterValues.req and StopTransaction.req messages. Default value of | ||
|
@@ -1364,6 +1387,11 @@ class UnitOfMeasureType(StrEnum): | |
k = "K" | ||
|
||
|
||
UnitOfMeasureType = DeprecatedEnumWrapper( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The library version is totally independent from the OCPP version supported. |
||
StandardizedUnitsOfMeasureType, "UnitOfMeasureType" | ||
) | ||
|
||
|
||
class StatusInfoReasonType(StrEnum): | ||
""" | ||
Standardized reason codes for StatusInfo defined in Appendix 5. v1.3 | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!