2323
2424from mock_vws ._constants import ResultCodes
2525from mock_vws ._mock_common import json_dump
26+ from ._constants import States
2627
2728
2829def compute_hmac_base64 (key : bytes , data : bytes ) -> bytes :
@@ -127,14 +128,14 @@ def validate_active_flag(
127128
128129
129130@wrapt .decorator
130- def validate_project_status (
131+ def validate_project_state (
131132 wrapped : Callable [..., str ],
132- instance : Any , # pylint: disable=unused-argument
133+ instance : Any ,
133134 args : Tuple [_RequestObjectProxy , _Context ],
134135 kwargs : Dict ,
135136) -> str :
136137 """
137- Validate the active flag data given to the endpoint .
138+ Validate the state of the project .
138139
139140 Args:
140141 wrapped: An endpoint function for `requests_mock`.
@@ -144,30 +145,26 @@ def validate_project_status(
144145
145146 Returns:
146147 The result of calling the endpoint.
147- A `BAD_REQUEST` response with a FAIL result code if there is
148- active flag data given to the endpoint which is not either a Boolean or
149- NULL.
150- """
148+ A `FORBIDDEN` response with a PROJECT_INACTIVE result code if the
149+ project is inactive.
150+ """
151151 request , context = args
152152
153- if not request . text :
153+ if instance . state != States . PROJECT_INACTIVE :
154154 return wrapped (* args , ** kwargs )
155155
156- if 'active_flag' not in request .json () :
156+ if request . method == 'GET' and 'duplicates' not in request .path :
157157 return wrapped (* args , ** kwargs )
158158
159- active_flag = request .json ().get ('active_flag' )
160-
161- if active_flag is None or isinstance (active_flag , bool ):
162- return wrapped (* args , ** kwargs )
159+ context .status_code = codes .FORBIDDEN
163160
164- context .status_code = codes .BAD_REQUEST
165161 body : Dict [str , str ] = {
166162 'transaction_id' : uuid .uuid4 ().hex ,
167- 'result_code' : ResultCodes .FAIL .value ,
163+ 'result_code' : ResultCodes .PROJECT_INACTIVE .value ,
168164 }
169165 return json_dump (body )
170166
167+
171168@wrapt .decorator
172169def validate_not_invalid_json (
173170 wrapped : Callable [..., str ],
0 commit comments