Skip to content

Commit 71e1b0a

Browse files
Merge pull request #1137 from adamtheturtle/target-id-on-target-status-processing
Handle exceptions which are not mocked
2 parents 177b0a9 + a9f151f commit 71e1b0a

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

src/vws/_result_codes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
Fail,
1414
ImageTooLarge,
1515
MetadataTooLarge,
16+
ProjectHasNoAPIAccess,
1617
ProjectInactive,
18+
ProjectSuspended,
1719
RequestQuotaReached,
1820
RequestTimeTooSkewed,
1921
TargetNameExist,
22+
TargetQuotaReached,
2023
TargetStatusNotSuccess,
2124
TargetStatusProcessing,
2225
UnknownTarget,
@@ -59,10 +62,13 @@ def raise_for_result_code(
5962
'ImageTooLarge': ImageTooLarge,
6063
'InactiveProject': ProjectInactive,
6164
'MetadataTooLarge': MetadataTooLarge,
65+
'ProjectHasNoAPIAccess': ProjectHasNoAPIAccess,
6266
'ProjectInactive': ProjectInactive,
67+
'ProjectSuspended': ProjectSuspended,
6368
'RequestQuotaReached': RequestQuotaReached,
6469
'RequestTimeTooSkewed': RequestTimeTooSkewed,
6570
'TargetNameExist': TargetNameExist,
71+
'TargetQuotaReached': TargetQuotaReached,
6672
'TargetStatusNotSuccess': TargetStatusNotSuccess,
6773
'TargetStatusProcessing': TargetStatusProcessing,
6874
'UnknownTarget': UnknownTarget,

src/vws/exceptions.py

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def target_id(self) -> str:
361361
return path.split(sep='/', maxsplit=2)[-1]
362362

363363

364-
# See https://github.com/adamtheturtle/vws-python/issues/846.
364+
# This is not simulated by the mock.
365365
class DateRangeError(Exception): # pragma: no cover
366366
"""
367367
Exception raised when Vuforia returns a response with a result code
@@ -384,6 +384,75 @@ def response(self) -> Response:
384384
return self._response
385385

386386

387+
# This is not simulated by the mock.
388+
class TargetQuotaReached(Exception): # pragma: no cover
389+
"""
390+
Exception raised when Vuforia returns a response with a result code
391+
'TargetQuotaReached'.
392+
"""
393+
394+
def __init__(self, response: Response) -> None:
395+
"""
396+
Args:
397+
response: The response to a request to Vuforia.
398+
"""
399+
super().__init__()
400+
self._response = response
401+
402+
@property
403+
def response(self) -> Response:
404+
"""
405+
The response returned by Vuforia which included this error.
406+
"""
407+
return self._response
408+
409+
410+
# This is not simulated by the mock.
411+
class ProjectSuspended(Exception): # pragma: no cover
412+
"""
413+
Exception raised when Vuforia returns a response with a result code
414+
'ProjectSuspended'.
415+
"""
416+
417+
def __init__(self, response: Response) -> None:
418+
"""
419+
Args:
420+
response: The response to a request to Vuforia.
421+
"""
422+
super().__init__()
423+
self._response = response
424+
425+
@property
426+
def response(self) -> Response:
427+
"""
428+
The response returned by Vuforia which included this error.
429+
"""
430+
return self._response
431+
432+
433+
# This is not simulated by the mock.
434+
class ProjectHasNoAPIAccess(Exception): # pragma: no cover
435+
"""
436+
Exception raised when Vuforia returns a response with a result code
437+
'ProjectHasNoAPIAccess'.
438+
"""
439+
440+
def __init__(self, response: Response) -> None:
441+
"""
442+
Args:
443+
response: The response to a request to Vuforia.
444+
"""
445+
super().__init__()
446+
self._response = response
447+
448+
@property
449+
def response(self) -> Response:
450+
"""
451+
The response returned by Vuforia which included this error.
452+
"""
453+
return self._response
454+
455+
387456
class TargetProcessingTimeout(Exception):
388457
"""
389458
Exception raised when waiting for a target to be processed times out.

0 commit comments

Comments
 (0)