File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed
Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1111 ImageTooLarge ,
1212 MetadataTooLarge ,
1313 ProjectInactive ,
14+ RequestTimeTooSkewed ,
1415 TargetNameExist ,
1516 TargetStatusNotSuccess ,
1617 TargetStatusProcessing ,
@@ -43,6 +44,7 @@ def raise_for_result_code(
4344 'InactiveProject' : ProjectInactive ,
4445 'MetadataTooLarge' : MetadataTooLarge ,
4546 'ProjectInactive' : ProjectInactive ,
47+ 'RequestTimeTooSkewed' : RequestTimeTooSkewed ,
4648 'TargetNameExist' : TargetNameExist ,
4749 'TargetStatusNotSuccess' : TargetStatusNotSuccess ,
4850 'TargetStatusProcessing' : TargetStatusProcessing ,
Original file line number Diff line number Diff line change @@ -203,6 +203,21 @@ def response(self) -> Response:
203203 return self ._response
204204
205205
206+ class RequestTimeTooSkewed (Exception ):
207+ """
208+ Exception raised when Vuforia returns a response with a result code
209+ 'RequestTimeTooSkewed'.
210+ """
211+
212+ def __init__ (self , response : Response ) -> None :
213+ """
214+ Args:
215+ response: The response to a request to Vuforia.
216+ """
217+ super ().__init__ ()
218+ self .response = response
219+
220+
206221class TargetNameExist (Exception ):
207222 """
208223 Exception raised when Vuforia returns a response with a result code
Original file line number Diff line number Diff line change 2424 MatchProcessing ,
2525 MetadataTooLarge ,
2626 ProjectInactive ,
27+ RequestTimeTooSkewed ,
2728 TargetNameExist ,
2829 TargetStatusNotSuccess ,
2930 TargetStatusProcessing ,
@@ -223,16 +224,12 @@ def test_metadata_too_large(
223224
224225
225226def test_request_time_too_skewed (vws_client : VWS ) -> None :
226- # TODO Use a flask-based mock so it is not affected by the time freeze
227- # or :( monkeypatch the time getting thing
228227 vws_max_time_skew = timedelta (minutes = 5 )
229228 leeway = timedelta (seconds = 10 )
230229 time_difference_from_now = vws_max_time_skew + leeway
231- gmt = pytz .timezone ('GMT' )
232- with freeze_time (datetime .now (tz = gmt ), auto_tick_seconds = 1000 ):
233- vws_client .get_target_record (target_id = 'a' )
234- # with pytest.raises(RequestTimeTooSkewed):
235- # pass
230+ with freeze_time (auto_tick_seconds = time_difference_from_now .seconds ):
231+ with pytest .raises (RequestTimeTooSkewed ):
232+ vws_client .get_target_record (target_id = 'a' )
236233
237234
238235def test_authentication_failure (high_quality_image : io .BytesIO ) -> None :
You can’t perform that action at this time.
0 commit comments