File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 55from requests import Response
66
77
8+ class MatchDeleted (Exception ):
9+ """
10+ Exception raised when a query is made with an image which matches a target
11+ which has recently been deleted.
12+ """
13+
14+ def __init__ (self , response : Response ) -> None :
15+ """
16+ Args:
17+ response: The response to a request to Vuforia.
18+ """
19+ super ().__init__ ()
20+ self ._response = response
21+
22+ @property
23+ def response (self ) -> Response :
24+ """
25+ The response returned by Vuforia which included this error.
26+ """
27+ return self ._response
28+
29+
830class MaxNumResultsOutOfRange (Exception ):
931 """
1032 Exception raised when the ``max_num_results`` given to the Cloud
Original file line number Diff line number Diff line change 1111
1212from ._authorization import authorization_header , rfc_1123_date
1313from ._result_codes import raise_for_result_code
14- from .exceptions import MaxNumResultsOutOfRange
14+ from .exceptions import MatchDeleted , MaxNumResultsOutOfRange
1515from .include_target_data import CloudRecoIncludeTargetData
1616
1717
@@ -105,6 +105,9 @@ def query(
105105 if 'Integer out of range' in response .text :
106106 raise MaxNumResultsOutOfRange (response = response )
107107
108+ if 'No content to map due to end-of-input' in response .text :
109+ raise MatchDeleted (response = response )
110+
108111 raise_for_result_code (
109112 response = response ,
110113 expected_result_code = 'Success' ,
Original file line number Diff line number Diff line change 1818 BadImage ,
1919 Fail ,
2020 ImageTooLarge ,
21+ MatchDeleted ,
2122 MetadataTooLarge ,
2223 ProjectInactive ,
2324 TargetNameExist ,
@@ -270,3 +271,24 @@ def test_target_status_not_success(
270271 vws_client .update_target (target_id = target_id )
271272
272273 assert exc .value .response .status_code == codes .FORBIDDEN
274+
275+
276+ def test_match_deleted (
277+ vws_client : VWS ,
278+ cloud_reco_client : CloudRecoService ,
279+ high_quality_image : io .BytesIO ,
280+ ) -> None :
281+ """
282+ A ``MatchDeleted`` exception is raised when a deleted target is matched.
283+ """
284+ target_id = vws_client .add_target (
285+ name = 'x' ,
286+ width = 1 ,
287+ image = high_quality_image ,
288+ )
289+ vws_client .wait_for_target_processed (target_id = target_id )
290+ vws_client .delete_target (target_id = target_id )
291+ with pytest .raises (MatchDeleted ) as exc :
292+ cloud_reco_client .query (image = high_quality_image )
293+
294+ assert exc .value .response .status_code == codes .INTERNAL_SERVER_ERROR
You can’t perform that action at this time.
0 commit comments