File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""
22Custom exceptions for Vuforia errors.
33"""
4+ from urllib .parse import urlparse
45
56import requests
67from requests import Response
@@ -89,6 +90,16 @@ def response(self) -> Response:
8990 """
9091 return self ._response
9192
93+ @property
94+ def target_id (self ) -> str :
95+ """
96+ The unknown target ID.
97+ """
98+ path = urlparse (self .response .url ).path
99+ # Every HTTP path which can raise this error is in the format
100+ # `/something/{target_id}`.
101+ return path .split (sep = '/' , maxsplit = 2 )[- 1 ]
102+
92103
93104class Fail (Exception ):
94105 """
Original file line number Diff line number Diff line change @@ -49,14 +49,16 @@ def test_image_too_large(
4949 assert exc .value .response .status_code == codes .UNPROCESSABLE_ENTITY
5050
5151
52- def test_invalid_given_id (vws_client : VWS ) -> None :
52+ @pytest .mark .parametrize ('target_id' , ['x' , 'x/1' ])
53+ def test_invalid_given_id (vws_client : VWS , target_id : str ) -> None :
5354 """
5455 Giving an invalid ID to a helper which requires a target ID to be given
5556 causes an ``UnknownTarget`` exception to be raised.
5657 """
5758 with pytest .raises (UnknownTarget ) as exc :
58- vws_client .delete_target (target_id = 'x' )
59+ vws_client .delete_target (target_id = target_id )
5960 assert exc .value .response .status_code == codes .NOT_FOUND
61+ assert exc .value .target_id == target_id
6062
6163
6264def test_add_bad_name (vws_client : VWS , high_quality_image : io .BytesIO ) -> None :
You can’t perform that action at this time.
0 commit comments