File tree Expand file tree Collapse file tree 3 files changed +46
-4
lines changed
Expand file tree Collapse file tree 3 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,18 @@ def __init__(self, response: Response) -> None:
1818 """
1919 super ().__init__ ()
2020 self .response = response
21+
22+
23+ class TargetStatusProcessing (Exception ):
24+ """
25+ Exception raised when Vuforia returns a response with a result code
26+ 'TargetStatusProcessing'.
27+ """
28+
29+ def __init__ (self , response : Response ) -> None :
30+ """
31+ Args:
32+ response: The response to a request to Vuforia.
33+ """
34+ super ().__init__ ()
35+ self .response = response
Original file line number Diff line number Diff line change 1515from requests import Response
1616
1717from vws ._authorization import authorization_header , rfc_1123_date
18- from vws .exceptions import UnknownTarget
18+ from vws .exceptions import TargetStatusProcessing , UnknownTarget
1919
2020
2121def _target_api_request (
@@ -106,6 +106,7 @@ class _ResultCodes(Enum):
106106
107107_EXCEPTIONS = {
108108 _ResultCodes .UNKNOWN_TARGET : UnknownTarget ,
109+ _ResultCodes .TARGET_STATUS_PROCESSING : TargetStatusProcessing ,
109110}
110111
111112
@@ -302,9 +303,9 @@ def delete_target(self, target_id: str) -> None:
302303 response = _target_api_request (
303304 server_access_key = self ._server_access_key ,
304305 server_secret_key = self ._server_secret_key ,
305- method = 'GET ' ,
306+ method = 'DELETE ' ,
306307 content = b'' ,
307- request_path = f'/summary /{ target_id } ' ,
308+ request_path = f'/targets /{ target_id } ' ,
308309 base_vws_url = self ._base_vws_url ,
309310 )
310311
Original file line number Diff line number Diff line change 44
55import io
66
7+ import pytest
8+ from requests import codes
9+
710from vws import VWS
11+ from vws .exceptions import TargetStatusProcessing , UnknownTarget
812
913
1014class TestDelete :
1115 """
1216 Test for deleting a target.
1317 """
1418
19+ def test_target_processing (
20+ self ,
21+ client : VWS ,
22+ high_quality_image : io .BytesIO ,
23+ ) -> None :
24+ """
25+ A ``TargetStatusProcessing`` exception is raised if trying to delete a
26+ target which is processing.
27+ """
28+ target_id = client .add_target (
29+ name = 'x' ,
30+ width = 1 ,
31+ image = high_quality_image ,
32+ )
33+
34+ with pytest .raises (TargetStatusProcessing ) as exc :
35+ client .delete_target (target_id = target_id )
36+
37+ assert exc .value .response .status_code == codes .FORBIDDEN
38+
1539 def test_delete_target (
1640 self ,
1741 client : VWS ,
1842 high_quality_image : io .BytesIO ,
1943 ) -> None :
2044 """
21- it is possible to delete a target.
45+ It is possible to delete a target.
2246 """
2347 target_id = client .add_target (
2448 name = 'x' ,
@@ -28,3 +52,5 @@ def test_delete_target(
2852
2953 client .wait_for_target_processed (target_id = target_id )
3054 client .delete_target (target_id = target_id )
55+ with pytest .raises (UnknownTarget ):
56+ client .get_target_record (target_id = target_id )
You can’t perform that action at this time.
0 commit comments