Skip to content

Commit 004c57b

Browse files
committed
Handle exceptions which are not mocked
1 parent 393fef8 commit 004c57b

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

src/vws/_result_codes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
Fail,
1414
ImageTooLarge,
1515
MetadataTooLarge,
16+
ProjectHasNoAPIAccess,
1617
ProjectInactive,
1718
RequestQuotaReached,
1819
RequestTimeTooSkewed,
1920
TargetNameExist,
21+
TargetQuotaReached,
2022
TargetStatusNotSuccess,
2123
TargetStatusProcessing,
2224
UnknownTarget,
@@ -59,10 +61,12 @@ def raise_for_result_code(
5961
'ImageTooLarge': ImageTooLarge,
6062
'InactiveProject': ProjectInactive,
6163
'MetadataTooLarge': MetadataTooLarge,
64+
'ProjectHasNoAPIAccess': ProjectHasNoAPIAccess,
6265
'ProjectInactive': ProjectInactive,
6366
'RequestQuotaReached': RequestQuotaReached,
6467
'RequestTimeTooSkewed': RequestTimeTooSkewed,
6568
'TargetNameExist': TargetNameExist,
69+
'TargetQuotaReached': TargetQuotaReached,
6670
'TargetStatusNotSuccess': TargetStatusNotSuccess,
6771
'TargetStatusProcessing': TargetStatusProcessing,
6872
'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)