File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,21 @@ def __init__(self, response: Response) -> None:
6565 self .response = response
6666
6767
68+ class ProjectInactive (Exception ):
69+ """
70+ Exception raised when Vuforia returns a response with a result code
71+ 'ProjectInactive'.
72+ """
73+
74+ def __init__ (self , response : Response ) -> None :
75+ """
76+ Args:
77+ response: The response to a request to Vuforia.
78+ """
79+ super ().__init__ ()
80+ self .response = response
81+
82+
6883class MetadataTooLarge (Exception ):
6984 """
7085 Exception raised when Vuforia returns a response with a result code
Original file line number Diff line number Diff line change 1919 Fail ,
2020 ImageTooLarge ,
2121 MetadataTooLarge ,
22+ ProjectInactive ,
2223 TargetNameExist ,
2324 TargetStatusProcessing ,
2425 UnknownTarget ,
@@ -105,6 +106,7 @@ def _raise_for_result_code(
105106 'Fail' : Fail ,
106107 'ImageTooLarge' : ImageTooLarge ,
107108 'MetadataTooLarge' : MetadataTooLarge ,
109+ 'ProjectInactive' : ProjectInactive ,
108110 'TargetNameExist' : TargetNameExist ,
109111 'TargetStatusProcessing' : TargetStatusProcessing ,
110112 'UnknownTarget' : UnknownTarget ,
Original file line number Diff line number Diff line change 66import random
77
88import pytest
9- from mock_vws import MockVWS
9+ from mock_vws import MockVWS , States
1010from PIL import Image
1111from requests import codes
1212
1616 Fail ,
1717 ImageTooLarge ,
1818 MetadataTooLarge ,
19+ ProjectInactive ,
1920 TargetNameExist ,
2021 TargetStatusProcessing ,
2122 UnknownTarget ,
@@ -138,6 +139,27 @@ def test_target_name_exist(
138139 assert exc .value .response .status_code == codes .FORBIDDEN
139140
140141
142+ def test_project_inactive (client : VWS , high_quality_image : io .BytesIO ) -> None :
143+ """
144+ A ``ProjectInactive`` exception is raised if adding a target to an
145+ inactive database.
146+ """
147+ with MockVWS (state = States .PROJECT_INACTIVE ) as mock :
148+ client = VWS (
149+ server_access_key = mock .server_access_key ,
150+ server_secret_key = mock .server_secret_key ,
151+ )
152+
153+ with pytest .raises (ProjectInactive ) as exc :
154+ client .add_target (
155+ name = 'x' ,
156+ width = 1 ,
157+ image = high_quality_image ,
158+ )
159+
160+ assert exc .value .response .status_code == codes .FORBIDDEN
161+
162+
141163def test_target_status_processing (
142164 client : VWS ,
143165 high_quality_image : io .BytesIO ,
You can’t perform that action at this time.
0 commit comments