Skip to content

Commit e78d722

Browse files
committed
Merge remote-tracking branch 'origin/master' into query-2
2 parents 772a262 + 65c497c commit e78d722

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

src/vws/query.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ def __init__(
2424
self,
2525
client_access_key: str,
2626
client_secret_key: str,
27-
# TODO - instead use/call this vwq URL
28-
base_vws_url: str = 'https://cloudreco.vuforia.com',
27+
base_vwq_url: str = 'https://cloudreco.vuforia.com',
2928
) -> None:
3029
"""
3130
Args:
3231
client_access_key: A VWS client access key.
3332
client_secret_key: A VWS client secret key.
34-
base_vws_url: The base URL for the VWS API.
33+
base_vwq_url: The base URL for the VWQ API.
3534
"""
3635
self._client_access_key = client_access_key.encode()
3736
self._client_secret_key = client_secret_key.encode()
@@ -84,7 +83,7 @@ def query(
8483

8584
response = requests.request(
8685
method=method,
87-
url=urljoin(base=self._base_vws_url, url=request_path),
86+
url=urljoin(base=self._base_vwq_url, url=request_path),
8887
headers=headers,
8988
data=content,
9089
)

tests/test_query.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import pytest
1010

11+
from mock_vws import MockVWS
12+
from mock_vws.database import VuforiaDatabase
13+
1114
from vws import VWS, CloudRecoService
1215
from vws.exceptions import AuthenticationFailure, MaxNumResultsOutOfRange
1316

@@ -47,6 +50,43 @@ def test_match(
4750
assert matching_target['target_id'] == target_id
4851

4952

53+
class TestCustomBaseVWQURL:
54+
"""
55+
Tests for using a custom base VWQ URL.
56+
"""
57+
58+
def test_custom_base_url(self, high_quality_image: io.BytesIO) -> None:
59+
"""
60+
It is possible to use query a target to a database under a custom VWQ
61+
URL.
62+
"""
63+
base_vwq_url = 'http://example.com'
64+
with MockVWS(base_vwq_url=base_vwq_url) as mock:
65+
database = VuforiaDatabase()
66+
mock.add_database(database=database)
67+
vws_client = VWS(
68+
server_access_key=database.server_access_key,
69+
server_secret_key=database.server_secret_key,
70+
)
71+
72+
target_id = vws_client.add_target(
73+
name='x',
74+
width=1,
75+
image=high_quality_image,
76+
)
77+
78+
vws_client.wait_for_target_processed(target_id=target_id)
79+
80+
cloud_reco_client = CloudRecoService(
81+
client_access_key=database.client_access_key,
82+
client_secret_key=database.client_secret_key,
83+
base_vwq_url=base_vwq_url,
84+
)
85+
86+
[match] = cloud_reco_client.query(image=high_quality_image)
87+
assert match['target_id'] == target_id
88+
89+
5090
class TestMaxNumResults:
5191
"""
5292
Tests for the ``max_num_results`` parameter of ``query``.

0 commit comments

Comments
 (0)