From 004c57b0d997e775b433224a4c090ea71315c427 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Dec 2019 01:05:36 +0000 Subject: [PATCH 1/2] Handle exceptions which are not mocked --- src/vws/_result_codes.py | 4 +++ src/vws/exceptions.py | 71 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/vws/_result_codes.py b/src/vws/_result_codes.py index 66965dd8a..182768b44 100644 --- a/src/vws/_result_codes.py +++ b/src/vws/_result_codes.py @@ -13,10 +13,12 @@ Fail, ImageTooLarge, MetadataTooLarge, + ProjectHasNoAPIAccess, ProjectInactive, RequestQuotaReached, RequestTimeTooSkewed, TargetNameExist, + TargetQuotaReached, TargetStatusNotSuccess, TargetStatusProcessing, UnknownTarget, @@ -59,10 +61,12 @@ def raise_for_result_code( 'ImageTooLarge': ImageTooLarge, 'InactiveProject': ProjectInactive, 'MetadataTooLarge': MetadataTooLarge, + 'ProjectHasNoAPIAccess': ProjectHasNoAPIAccess, 'ProjectInactive': ProjectInactive, 'RequestQuotaReached': RequestQuotaReached, 'RequestTimeTooSkewed': RequestTimeTooSkewed, 'TargetNameExist': TargetNameExist, + 'TargetQuotaReached': TargetQuotaReached, 'TargetStatusNotSuccess': TargetStatusNotSuccess, 'TargetStatusProcessing': TargetStatusProcessing, 'UnknownTarget': UnknownTarget, diff --git a/src/vws/exceptions.py b/src/vws/exceptions.py index 928d41c54..291f19c43 100644 --- a/src/vws/exceptions.py +++ b/src/vws/exceptions.py @@ -361,7 +361,7 @@ def target_id(self) -> str: return path.split(sep='/', maxsplit=2)[-1] -# See https://github.com/adamtheturtle/vws-python/issues/846. +# This is not simulated by the mock. class DateRangeError(Exception): # pragma: no cover """ Exception raised when Vuforia returns a response with a result code @@ -384,6 +384,75 @@ def response(self) -> Response: return self._response +# This is not simulated by the mock. +class TargetQuotaReached(Exception): # pragma: no cover + """ + Exception raised when Vuforia returns a response with a result code + 'TargetQuotaReached'. + """ + + def __init__(self, response: Response) -> None: + """ + Args: + response: The response to a request to Vuforia. + """ + super().__init__() + self._response = response + + @property + def response(self) -> Response: + """ + The response returned by Vuforia which included this error. + """ + return self._response + + +# This is not simulated by the mock. +class ProjectSuspended(Exception): # pragma: no cover + """ + Exception raised when Vuforia returns a response with a result code + 'ProjectSuspended'. + """ + + def __init__(self, response: Response) -> None: + """ + Args: + response: The response to a request to Vuforia. + """ + super().__init__() + self._response = response + + @property + def response(self) -> Response: + """ + The response returned by Vuforia which included this error. + """ + return self._response + + +# This is not simulated by the mock. +class ProjectHasNoAPIAccess(Exception): # pragma: no cover + """ + Exception raised when Vuforia returns a response with a result code + 'ProjectHasNoAPIAccess'. + """ + + def __init__(self, response: Response) -> None: + """ + Args: + response: The response to a request to Vuforia. + """ + super().__init__() + self._response = response + + @property + def response(self) -> Response: + """ + The response returned by Vuforia which included this error. + """ + return self._response + + class TargetProcessingTimeout(Exception): """ Exception raised when waiting for a target to be processed times out. From a9f151fac965487050c49095961d0597c7a9984b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Dec 2019 01:06:50 +0000 Subject: [PATCH 2/2] Handle exceptions which are not mocked --- src/vws/_result_codes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vws/_result_codes.py b/src/vws/_result_codes.py index 182768b44..99c9d84dd 100644 --- a/src/vws/_result_codes.py +++ b/src/vws/_result_codes.py @@ -15,6 +15,7 @@ MetadataTooLarge, ProjectHasNoAPIAccess, ProjectInactive, + ProjectSuspended, RequestQuotaReached, RequestTimeTooSkewed, TargetNameExist, @@ -63,6 +64,7 @@ def raise_for_result_code( 'MetadataTooLarge': MetadataTooLarge, 'ProjectHasNoAPIAccess': ProjectHasNoAPIAccess, 'ProjectInactive': ProjectInactive, + 'ProjectSuspended': ProjectSuspended, 'RequestQuotaReached': RequestQuotaReached, 'RequestTimeTooSkewed': RequestTimeTooSkewed, 'TargetNameExist': TargetNameExist,