diff --git a/src/edutap/wallet_google/models/primitives/enums.py b/src/edutap/wallet_google/models/primitives/enums.py index 9815400..2915175 100644 --- a/src/edutap/wallet_google/models/primitives/enums.py +++ b/src/edutap/wallet_google/models/primitives/enums.py @@ -33,7 +33,18 @@ def __new__(cls: type["CamelCaseAliasEnum"], value: str) -> "CamelCaseAliasEnum" cls._member_names_.append(camel) return obj - + def __eq__(self, other: Enum) -> bool: + """Allow comparison with the camelcase value. + take into account that UPPER_CASE and camelCase are equal + """ + if self.value == other.value: + return True + else: + v1 = self.value.lower().replace("_", "") + v2 = other.value.lower().replace("_", "") + return v1 == v2 + + class Action(CamelCaseAliasEnum): """ see: https://developers.google.com/wallet/generic/rest/v1/smarttap#action diff --git a/tests/test_enum.py b/tests/test_enum.py index 31665ac..16ecd4c 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -12,6 +12,8 @@ def test_action_enum(): assert Action("ACTION_UNSPECIFIED") == Action.ACTION_UNSPECIFIED assert Action("actionUnspecified") == Action.ACTION_UNSPECIFIED + + assert Action("S2AP") != Action.ACTION_UNSPECIFIED assert Action("S2AP") == Action.S2AP assert Action("s2ap") == Action.S2AP