Skip to content

Commit 7969328

Browse files
committed
Switch from constantly to Enum
1 parent e749b60 commit 7969328

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

src/mock_vws/_constants.py

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
Constants used to make the VWS mock.
33
"""
44

5-
from constantly import NamedConstant, Names, ValueConstant, Values
5+
from enum import Enum, auto
66

77

8-
class States(Names): # type: ignore
8+
class States(Enum):
99
"""
1010
Constants representing various web service states.
1111
"""
1212

13-
WORKING = NamedConstant()
13+
WORKING = auto()
1414

1515
# A project is inactive if the license key has been deleted.
16-
PROJECT_INACTIVE = NamedConstant()
16+
PROJECT_INACTIVE = auto()
1717

18+
def __repr__(self) -> str:
19+
"""
20+
The representation should not include the generated number.
21+
"""
22+
return '<{class_name}.{state_name}>'.format(
23+
class_name=self.__class__.__name__,
24+
state_name=self.name,
25+
)
1826

19-
class ResultCodes(Values): # type: ignore
27+
28+
class ResultCodes(Enum):
2029
"""
2130
Constants representing various VWS result codes.
2231
@@ -26,31 +35,31 @@ class ResultCodes(Values): # type: ignore
2635
Some codes here are not documented in the above link.
2736
"""
2837

29-
SUCCESS = ValueConstant('Success')
30-
TARGET_CREATED = ValueConstant('TargetCreated')
31-
AUTHENTICATION_FAILURE = ValueConstant('AuthenticationFailure')
32-
REQUEST_TIME_TOO_SKEWED = ValueConstant('RequestTimeTooSkewed')
33-
TARGET_NAME_EXIST = ValueConstant('TargetNameExist')
34-
UNKNOWN_TARGET = ValueConstant('UnknownTarget')
35-
BAD_IMAGE = ValueConstant('BadImage')
36-
IMAGE_TOO_LARGE = ValueConstant('ImageTooLarge')
37-
METADATA_TOO_LARGE = ValueConstant('MetadataTooLarge')
38-
DATE_RANGE_ERROR = ValueConstant('DateRangeError')
39-
FAIL = ValueConstant('Fail')
40-
TARGET_STATUS_PROCESSING = ValueConstant('TargetStatusProcessing')
41-
REQUEST_QUOTA_REACHED = ValueConstant('RequestQuotaReached')
42-
TARGET_STATUS_NOT_SUCCESS = ValueConstant('TargetStatusNotSuccess')
43-
PROJECT_INACTIVE = ValueConstant('ProjectInactive')
44-
45-
46-
class TargetStatuses(Values): # type: ignore
38+
SUCCESS = 'Success'
39+
TARGET_CREATED = 'TargetCreated'
40+
AUTHENTICATION_FAILURE = 'AuthenticationFailure'
41+
REQUEST_TIME_TOO_SKEWED = 'RequestTimeTooSkewed'
42+
TARGET_NAME_EXIST = 'TargetNameExist'
43+
UNKNOWN_TARGET = 'UnknownTarget'
44+
BAD_IMAGE = 'BadImage'
45+
IMAGE_TOO_LARGE = 'ImageTooLarge'
46+
METADATA_TOO_LARGE = 'MetadataTooLarge'
47+
DATE_RANGE_ERROR = 'DateRangeError'
48+
FAIL = 'Fail'
49+
TARGET_STATUS_PROCESSING = 'TargetStatusProcessing'
50+
REQUEST_QUOTA_REACHED = 'RequestQuotaReached'
51+
TARGET_STATUS_NOT_SUCCESS = 'TargetStatusNotSuccess'
52+
PROJECT_INACTIVE = 'ProjectInactive'
53+
54+
55+
class TargetStatuses(Enum):
4756
"""
4857
Constants representing VWS target statuses.
4958
5059
See the 'status' field in
5160
https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API.html#How-To-Retrieve-a-Target-Record
5261
"""
5362

54-
PROCESSING = ValueConstant('processing') # type: TargetStatuses
55-
SUCCESS = ValueConstant('success') # type: TargetStatuses
56-
FAILED = ValueConstant('failed') # type: TargetStatuses
63+
PROCESSING = 'processing'
64+
SUCCESS = 'success'
65+
FAILED = 'failed'

0 commit comments

Comments
 (0)