File tree Expand file tree Collapse file tree 4 files changed +54
-3
lines changed
Expand file tree Collapse file tree 4 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 88from urllib .parse import urljoin
99
1010import requests
11- from beartype import beartype
11+ from beartype import BeartypeConf , beartype
1212from urllib3 .filepost import encode_multipart_formdata
1313from vws_auth_tools import authorization_header , rfc_1123_date
1414
@@ -40,7 +40,7 @@ def _get_image_data(image: _ImageType) -> bytes:
4040 return image_data
4141
4242
43- @beartype
43+ @beartype ( conf = BeartypeConf ( is_pep484_tower = True ))
4444class CloudRecoService :
4545 """An interface to the Vuforia Cloud Recognition Web APIs."""
4646
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ def _get_image_data(image: _ImageType) -> bytes:
5858 return image_data
5959
6060
61- @beartype
61+ @beartype ( conf = BeartypeConf ( is_pep484_tower = True ))
6262def _target_api_request (
6363 * ,
6464 content_type : str ,
Original file line number Diff line number Diff line change @@ -93,6 +93,35 @@ def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None:
9393 matches = cloud_reco_client .query (image = image )
9494 assert len (matches ) == 1
9595
96+ @staticmethod
97+ def test_custom_timeout_int (image : io .BytesIO | BinaryIO ) -> None :
98+ """It is possible to set a custom request timeout as an int."""
99+ with MockVWS () as mock :
100+ database = VuforiaDatabase ()
101+ mock .add_database (database = database )
102+ vws_client = VWS (
103+ server_access_key = database .server_access_key ,
104+ server_secret_key = database .server_secret_key ,
105+ )
106+ custom_timeout = 60
107+ cloud_reco_client = CloudRecoService (
108+ client_access_key = database .client_access_key ,
109+ client_secret_key = database .client_secret_key ,
110+ request_timeout_seconds = custom_timeout ,
111+ )
112+ assert cloud_reco_client .request_timeout_seconds == custom_timeout
113+
114+ target_id = vws_client .add_target (
115+ name = "x" ,
116+ width = 1 ,
117+ image = image ,
118+ active_flag = True ,
119+ application_metadata = None ,
120+ )
121+ vws_client .wait_for_target_processed (target_id = target_id )
122+ matches = cloud_reco_client .query (image = image )
123+ assert len (matches ) == 1
124+
96125 @staticmethod
97126 def test_custom_timeout_tuple (image : io .BytesIO | BinaryIO ) -> None :
98127 """It is possible to set separate connect and read timeouts."""
Original file line number Diff line number Diff line change @@ -135,6 +135,28 @@ def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None:
135135 application_metadata = None ,
136136 )
137137
138+ @staticmethod
139+ def test_custom_timeout_int (image : io .BytesIO | BinaryIO ) -> None :
140+ """It is possible to set a custom request timeout as an int."""
141+ with MockVWS () as mock :
142+ database = VuforiaDatabase ()
143+ mock .add_database (database = database )
144+ custom_timeout = 60
145+ vws_client = VWS (
146+ server_access_key = database .server_access_key ,
147+ server_secret_key = database .server_secret_key ,
148+ request_timeout_seconds = custom_timeout ,
149+ )
150+ assert vws_client .request_timeout_seconds == custom_timeout
151+
152+ vws_client .add_target (
153+ name = "x" ,
154+ width = 1 ,
155+ image = image ,
156+ active_flag = True ,
157+ application_metadata = None ,
158+ )
159+
138160 @staticmethod
139161 def test_custom_timeout_tuple (image : io .BytesIO | BinaryIO ) -> None :
140162 """It is possible to set separate connect and read timeouts."""
You can’t perform that action at this time.
0 commit comments