Skip to content

Commit 772a262

Browse files
committed
Merge remote-tracking branch 'origin/master' into query-2
2 parents 2972c4d + 2fa5401 commit 772a262

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests==2.22.0
22
timeout-decorator==0.4.1
3+
urllib3==1.25.3

src/vws/query.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
"""
2+
Tools for interacting with the Vuforia Cloud Recognition Web APIs.
3+
"""
4+
15
import io
2-
import json
6+
from typing import Any, Dict, List
37
from urllib.parse import urljoin
48

59
import requests
@@ -13,7 +17,7 @@
1317

1418
class CloudRecoService:
1519
"""
16-
TODO
20+
An interface to the Vuforia Cloud Recognition Web APIs.
1721
"""
1822

1923
def __init__(
@@ -37,9 +41,19 @@ def query(
3741
self,
3842
image: io.BytesIO,
3943
max_num_results: int = 1,
40-
) -> str:
44+
) -> List[Dict[str, Any]]:
4145
"""
42-
TODO docstring
46+
Use the Vuforia Web Query API to make an Image Recognition Query.
47+
48+
See
49+
https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query
50+
for parameter details.
51+
52+
Args:
53+
image: The image to make a query against.
54+
55+
Returns:
56+
An ordered list of target details of matching targets.
4357
"""
4458
image_content = image.getvalue()
4559
body = {
@@ -79,4 +93,4 @@ def query(
7993
raise MaxNumResultsOutOfRange(response=response)
8094

8195
raise_for_result_code(response=response, expected_result_code='Success')
82-
return response.json()['results']
96+
return list(response.json()['results'])

tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _mock_database() -> Iterator[VuforiaDatabase]:
2929
@pytest.fixture()
3030
def vws_client(_mock_database: VuforiaDatabase) -> Iterator[VWS]:
3131
"""
32-
Yield a VWS client which connects to a mock.
32+
Yield a VWS client which connects to a mock database.
3333
"""
3434
yield VWS(
3535
server_access_key=_mock_database.server_access_key,
@@ -38,9 +38,10 @@ def vws_client(_mock_database: VuforiaDatabase) -> Iterator[VWS]:
3838

3939

4040
@pytest.fixture()
41-
def cloud_reco_client(_mock_database: VuforiaDatabase) -> Iterator[VWS]:
41+
def cloud_reco_client(_mock_database: VuforiaDatabase,
42+
) -> Iterator[CloudRecoService]:
4243
"""
43-
TODO Docstring
44+
Yield a ``CloudRecoService`` client which connects to a mock database.
4445
"""
4546
yield CloudRecoService(
4647
client_access_key=_mock_database.client_access_key,

tests/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
TODO
2+
Tests for the ``CloudRecoService`` querying functionality.
33
"""
44

55
import io
@@ -14,7 +14,7 @@
1414

1515
class TestQuery:
1616
"""
17-
TODO
17+
Tests for making image queries.
1818
"""
1919

2020
def test_no_matches(

0 commit comments

Comments
 (0)