Skip to content

Commit c1bc296

Browse files
committed
Start updating exceptions and exception handling to match new Vuforia behaviour
1 parent 1bf2b74 commit c1bc296

File tree

3 files changed

+14
-37
lines changed

3 files changed

+14
-37
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ Changelog
66
Next
77
----
88

9-
2020.09.28.0
10-
------------
11-
12-
2020.09.25.0
13-
------------
14-
15-
2020.09.08.0
16-
------------
9+
* Breaking change: The ``vws.exceptions.cloud_reco_exceptions.MatchProcessing`` is now ``vws.exceptions.custom_exceptions.ActiveMatchingTargetsDeleteProcessing``.
10+
* Added new exception ``vws.exceptions.custom_exceptions.RequestEntityTooLarge``.
1711

1812
2020.09.07.0
1913
------------

src/vws/query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
AuthenticationFailure,
1818
BadImage,
1919
InactiveProject,
20-
MatchProcessing,
2120
MaxNumResultsOutOfRange,
2221
RequestTimeTooSkewed,
2322
)
2423
from vws.exceptions.custom_exceptions import (
2524
RequestEntityTooLarge,
25+
ActiveMatchingTargetsDeleteProcessing,
2626
)
2727
from vws.include_target_data import CloudRecoIncludeTargetData
2828
from vws.reports import QueryResult, TargetData
@@ -78,9 +78,9 @@ def query(
7878
client access key pair is not correct.
7979
~vws.exceptions.cloud_reco_exceptions.MaxNumResultsOutOfRange:
8080
``max_num_results`` is not within the range (1, 50).
81-
~vws.exceptions.cloud_reco_exceptions.MatchProcessing: The given
82-
image matches a target which was recently added, updated or
83-
deleted and Vuforia returns an error in this case.
81+
~vws.exceptions.cloud_reco_exceptions.ActiveMatchingTargetsDeleteProcessing: The given
82+
image matches a target which was recently
83+
deleted.
8484
~vws.exceptions.cloud_reco_exceptions.InactiveProject: The project
8585
is inactive.
8686
~vws.exceptions.cloud_reco_exceptions.RequestTimeTooSkewed: There
@@ -140,7 +140,7 @@ def query(
140140
raise MaxNumResultsOutOfRange(response=response)
141141

142142
if 'No content to map due to end-of-input' in response.text:
143-
raise MatchProcessing(response=response)
143+
raise ActiveMatchingTargetsDeleteProcessing(response=response)
144144

145145
result_code = response.json()['result_code']
146146
if result_code != 'Success':

tests/test_cloud_reco_exceptions.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import io
6+
import time
67
from http import HTTPStatus
78

89
import pytest
@@ -68,28 +69,6 @@ def test_cloudrecoexception_inheritance() -> None:
6869
assert issubclass(subclass, CloudRecoException)
6970

7071

71-
def test_base_exception(
72-
vws_client: VWS,
73-
cloud_reco_client: CloudRecoService,
74-
high_quality_image: io.BytesIO,
75-
) -> None:
76-
"""
77-
``CloudRecoException``s has a response property.
78-
"""
79-
vws_client.add_target(
80-
name='x',
81-
width=1,
82-
image=high_quality_image,
83-
active_flag=True,
84-
application_metadata=None,
85-
)
86-
87-
with pytest.raises(CloudRecoException) as exc:
88-
cloud_reco_client.query(image=high_quality_image)
89-
90-
assert exc.value.response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR
91-
92-
9372
def test_match_processing(
9473
vws_client: VWS,
9574
cloud_reco_client: CloudRecoService,
@@ -99,15 +78,19 @@ def test_match_processing(
9978
A ``MatchProcessing`` exception is raised when a target in processing is
10079
matched.
10180
"""
102-
vws_client.add_target(
81+
target_id = vws_client.add_target(
10382
name='x',
10483
width=1,
10584
image=high_quality_image,
10685
active_flag=True,
10786
application_metadata=None,
10887
)
88+
vws_client.wait_for_target_processed(target_id=target_id)
89+
vws_client.delete_target(target_id=target_id)
90+
time.sleep(0.2)
10991
with pytest.raises(MatchProcessing) as exc:
110-
cloud_reco_client.query(image=high_quality_image)
92+
response = cloud_reco_client.query(image=high_quality_image)
93+
11194
assert exc.value.response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR
11295

11396

0 commit comments

Comments
 (0)