test_enums.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # test_enums.py/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
  2. # This copyright was auto-generated on Wed Aug 16 22:48:50 UTC 2023
  3. # Note: This may seem trivial but there were some major changes around this in Python 3.11
  4. import enum
  5. from open_gopro.domain.enum import GoProIntEnum, enum_factory
  6. from open_gopro.models import proto
  7. class EnumTest(GoProIntEnum):
  8. RESULT_SUCCESS = 1
  9. TWO = 2
  10. NOT_APPLICABLE = 3
  11. DESCRIPTOR = 4
  12. FIVE = 5
  13. class NormalEnum(enum.Enum):
  14. TWO = 2
  15. def test_str():
  16. assert EnumTest.TWO.name == "TWO"
  17. assert EnumTest.TWO.value == 2
  18. assert str(EnumTest.TWO) == "EnumTest.TWO"
  19. def test_equal():
  20. assert EnumTest.TWO == 2
  21. assert not EnumTest.TWO == "TWO"
  22. assert not EnumTest.TWO == NormalEnum.TWO
  23. assert EnumTest.TWO == EnumTest.TWO
  24. def test_proto_enum_equal():
  25. proto_enum = enum_factory(proto.EnumResultGeneric.DESCRIPTOR)
  26. assert proto_enum.RESULT_SUCCESS == 1
  27. assert proto_enum.RESULT_SUCCESS == EnumTest.RESULT_SUCCESS
  28. assert proto_enum.RESULT_SUCCESS == "RESULT_SUCCESS"
  29. def test_special_values():
  30. assert EnumTest.FIVE in list(EnumTest)
  31. assert EnumTest.FIVE in EnumTest
  32. assert EnumTest.NOT_APPLICABLE not in list(EnumTest)
  33. assert EnumTest.DESCRIPTOR not in list(EnumTest)