Skip to content

Commit 0e98ad2

Browse files
committed
Test passes on real
1 parent bb4f4ca commit 0e98ad2

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

tests/mock_vws/test_query.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
import base64
88
import calendar
9+
import datetime
910
import io
1011
import time
1112
from typing import Dict, Union
1213
from urllib.parse import urljoin
1314

1415
import pytest
16+
import pytz
1517
import requests
1618
from PIL import Image
1719
from requests import codes
@@ -1618,17 +1620,50 @@ class TestDateFormats:
16181620
> header.
16191621
"""
16201622

1623+
@pytest.mark.parametrize('datetime_format', [
1624+
'%a %b %d %H:%M:%S %Y',
1625+
])
16211626
def test_date_formats(
16221627
self,
16231628
high_quality_image: io.BytesIO,
16241629
vuforia_database_keys: VuforiaDatabaseKeys,
1630+
datetime_format: str,
16251631
) -> None:
16261632
image_content = high_quality_image.getvalue()
16271633
body = {'image': ('image.jpeg', image_content, 'image/jpeg')}
16281634

1629-
response = query(
1630-
vuforia_database_keys=vuforia_database_keys,
1631-
body=body,
1635+
gmt = pytz.timezone('GMT')
1636+
now = datetime.datetime.now(tz=gmt)
1637+
date = now.strftime(datetime_format)
1638+
request_path = '/v1/query'
1639+
content, content_type_header = encode_multipart_formdata(body)
1640+
method = POST
1641+
1642+
access_key = vuforia_database_keys.client_access_key
1643+
secret_key = vuforia_database_keys.client_secret_key
1644+
authorization_string = authorization_header(
1645+
access_key=access_key,
1646+
secret_key=secret_key,
1647+
method=method,
1648+
content=content,
1649+
# Note that this is not the actual Content-Type header value sent.
1650+
content_type='multipart/form-data',
1651+
date=date,
1652+
request_path=request_path,
1653+
)
1654+
1655+
headers = {
1656+
'Authorization': authorization_string,
1657+
'Date': date,
1658+
'Content-Type': content_type_header,
1659+
}
1660+
1661+
vwq_host = 'https://cloudreco.vuforia.com'
1662+
response = requests.request(
1663+
method=method,
1664+
url=urljoin(base=vwq_host, url=request_path),
1665+
headers=headers,
1666+
data=content,
16321667
)
16331668

16341669
assert_query_success(response=response)

0 commit comments

Comments
 (0)