|
1 | 1 | """Tests for helper functions for managing a Vuforia database.""" |
2 | 2 |
|
3 | 3 | import base64 |
| 4 | +import contextlib |
4 | 5 | import datetime |
5 | 6 | import io |
6 | 7 | import secrets |
|
15 | 16 |
|
16 | 17 | from vws import VWS, CloudRecoService, VuMarkService |
17 | 18 | from vws.exceptions.custom_exceptions import TargetProcessingTimeoutError |
| 19 | +from vws.exceptions.vws_exceptions import UnknownTargetError |
18 | 20 | from vws.reports import ( |
19 | 21 | DatabaseSummaryReport, |
20 | 22 | TargetRecord, |
@@ -252,19 +254,25 @@ def test_custom_base_url_with_path_prefix() -> None: |
252 | 254 | A base VWS URL with a path prefix is used as-is, without the |
253 | 255 | prefix being dropped. |
254 | 256 | """ |
255 | | - with MockVWS(base_vws_url="http://example.com") as mock: |
| 257 | + base_vws_url = "http://example.com/prefix" |
| 258 | + with MockVWS(base_vws_url=base_vws_url) as mock: |
256 | 259 | database = CloudDatabase() |
257 | 260 | mock.add_cloud_database(cloud_database=database) |
258 | 261 | vws_client = VWS( |
259 | 262 | server_access_key=database.server_access_key, |
260 | 263 | server_secret_key=database.server_secret_key, |
261 | | - base_vws_url="http://example.com/prefix", |
| 264 | + base_vws_url=base_vws_url, |
262 | 265 | ) |
263 | 266 |
|
264 | | - with pytest.raises( |
265 | | - expected_exception=requests.exceptions.ConnectionError, |
266 | | - ): |
267 | | - vws_client.list_targets() |
| 267 | + # MockVWS's path-length check in validate_target_id_exists |
| 268 | + # does not account for a base URL path prefix, so it |
| 269 | + # incorrectly treats the last path segment ("targets") as a |
| 270 | + # target ID and raises UnknownTargetError. |
| 271 | + # See https://github.com/VWS-Python/vws-python-mock/issues/2995 |
| 272 | + # The request did reach MockVWS (proving the prefix was |
| 273 | + # preserved in the URL), so this exception is expected for now. |
| 274 | + with contextlib.suppress(UnknownTargetError): |
| 275 | + assert vws_client.list_targets() == [] |
268 | 276 |
|
269 | 277 |
|
270 | 278 | class TestListTargets: |
|
0 commit comments