Skip to content

Commit 55d86eb

Browse files
committed
Add test for auth failure
1 parent 6dd5277 commit 55d86eb

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PyYAML==3.13
22
Pygments==2.2.0
3-
VWS-Python-Mock==2018.10.01.1
3+
VWS-Python-Mock==2018.10.02.0
44
autoflake==1.2
55
check-manifest==0.37
66
codecov==2.0.15 # Upload coverage data

tests/test_exceptions.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_request_quota_reached() -> None:
9797

9898
def test_fail(high_quality_image: io.BytesIO) -> None:
9999
"""
100-
A ``Fail`` exception is raised when there are authentication issues.
100+
A ``Fail`` exception is raised when the server access key does not exist.
101101
"""
102102
with MockVWS():
103103
client = VWS(
@@ -201,3 +201,26 @@ def test_metadata_too_large(
201201
)
202202

203203
assert exc.value.response.status_code == codes.UNPROCESSABLE_ENTITY
204+
205+
206+
def test_authentication_failure(high_quality_image: io.BytesIO) -> None:
207+
"""
208+
An ``AuthenticationFailure`` exception is raised when the server access key
209+
does not exist.
210+
"""
211+
database = VuforiaDatabase()
212+
with MockVWS() as mock:
213+
mock.add_database(database=database)
214+
client = VWS(
215+
server_access_key=database.server_access_key.decode(),
216+
server_secret_key='a',
217+
)
218+
219+
with pytest.raises(AuthenticationFailure) as exc:
220+
client.add_target(
221+
name='x',
222+
width=1,
223+
image=high_quality_image,
224+
)
225+
226+
assert exc.value.response.status_code == codes.UNAUTHORIZED

0 commit comments

Comments
 (0)