Skip to content

Commit 0c8c4aa

Browse files
Merge pull request #448 from adamtheturtle/ready-add
Ready add
2 parents 1c3ddca + 62a2a7d commit 0c8c4aa

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/mock_vws/fixtures/prepared_requests.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Fixtures which prepare requests.
33
"""
44

5+
import base64
6+
import io
57
import json
68
from typing import Any, Dict
79
from urllib.parse import urljoin
@@ -26,12 +28,19 @@
2628
@pytest.fixture()
2729
def _add_target(
2830
vuforia_database_keys: VuforiaDatabaseKeys,
31+
png_rgb: io.BytesIO,
2932
) -> TargetAPIEndpoint:
3033
"""
3134
Return details of the endpoint for adding a target.
3235
"""
36+
image_data = png_rgb.read()
37+
image_data_encoded = base64.b64encode(image_data).decode('ascii')
3338
date = rfc_1123_date()
34-
data: Dict[str, Any] = {}
39+
data: Dict[str, Any] = {
40+
'name': 'example_name',
41+
'width': 1,
42+
'image': image_data_encoded,
43+
}
3544
request_path = '/targets'
3645
content_type = 'application/json'
3746
method = POST
@@ -66,10 +75,8 @@ def _add_target(
6675
prepared_request = request.prepare() # type: ignore
6776

6877
return TargetAPIEndpoint(
69-
# We expect a bad request error because we have not given the required
70-
# JSON body elements.
71-
successful_headers_status_code=codes.BAD_REQUEST,
72-
successful_headers_result_code=ResultCodes.FAIL,
78+
successful_headers_status_code=codes.CREATED,
79+
successful_headers_result_code=ResultCodes.TARGET_CREATED,
7380
prepared_request=prepared_request,
7481
access_key=access_key,
7582
secret_key=secret_key,
@@ -397,7 +404,7 @@ def _update_target(
397404
)
398405
data: Dict[str, Any] = {}
399406
request_path = f'/targets/{target_id}'
400-
content = bytes(str(data), encoding='utf-8')
407+
content = bytes(json.dumps(data), encoding='utf-8')
401408
content_type = 'application/json'
402409

403410
date = rfc_1123_date()

0 commit comments

Comments
 (0)