Skip to content

Commit 2980360

Browse files
committed
Remove one more use of a custom helper
1 parent d2156b6 commit 2980360

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

tests/mock_vws/test_add_target.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import annotations
66

77
import base64
8+
import io
89
import json
910
from http import HTTPMethod, HTTPStatus
1011
from string import hexdigits
@@ -18,6 +19,7 @@
1819
from requests.structures import CaseInsensitiveDict
1920
from vws.exceptions.custom_exceptions import OopsAnErrorOccurredPossiblyBadName
2021
from vws.exceptions.vws_exceptions import (
22+
BadImage,
2123
Fail,
2224
ImageTooLarge,
2325
MetadataTooLarge,
@@ -34,8 +36,6 @@
3436
from tests.mock_vws.utils.too_many_requests import handle_server_errors
3537

3638
if TYPE_CHECKING:
37-
import io
38-
3939
from mock_vws.database import VuforiaDatabase
4040
from vws import VWS
4141
from vws.exceptions.response import Response
@@ -687,29 +687,22 @@ def test_not_base64_encoded_not_processable(
687687
)
688688

689689
@staticmethod
690-
def test_not_image(
691-
vuforia_database: VuforiaDatabase,
692-
) -> None:
690+
def test_not_image(vws_client: VWS) -> None:
693691
"""
694692
If the given image is not an image file then a `BadImage` result is
695693
returned.
696694
"""
697-
not_image_data = b"not_image_data"
698-
image_data_encoded = base64.b64encode(s=not_image_data).decode("ascii")
699-
700-
data = {
701-
"name": "example_name",
702-
"width": 1,
703-
"image": image_data_encoded,
704-
}
705-
706-
response = _add_target_to_vws(
707-
vuforia_database=vuforia_database,
708-
data=data,
709-
)
695+
with pytest.raises(expected_exception=BadImage) as exc:
696+
vws_client.add_target(
697+
name="example_name",
698+
width=1,
699+
image=io.BytesIO(initial_bytes=b"not_image_data"),
700+
application_metadata=None,
701+
active_flag=True,
702+
)
710703

711704
assert_vws_failure(
712-
response=response,
705+
response=exc.value.response,
713706
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
714707
result_code=ResultCodes.BAD_IMAGE,
715708
)

0 commit comments

Comments
 (0)