|
5 | 5 | import io |
6 | 6 | import uuid |
7 | 7 |
|
| 8 | +from mock_vws import MockVWS |
| 9 | +from mock_vws.database import VuforiaDatabase |
| 10 | + |
8 | 11 | from vws import VWS, CloudRecoService |
9 | 12 |
|
10 | 13 |
|
@@ -43,6 +46,43 @@ def test_match( |
43 | 46 | assert matching_target['target_id'] == target_id |
44 | 47 |
|
45 | 48 |
|
| 49 | +class TestCustomBaseVWQURL: |
| 50 | + """ |
| 51 | + Tests for using a custom base VWQ URL. |
| 52 | + """ |
| 53 | + |
| 54 | + def test_custom_base_url(self, high_quality_image: io.BytesIO) -> None: |
| 55 | + """ |
| 56 | + It is possible to use query a target to a database under a custom VWQ |
| 57 | + URL. |
| 58 | + """ |
| 59 | + base_vwq_url = 'http://example.com' |
| 60 | + with MockVWS(base_vwq_url=base_vwq_url) as mock: |
| 61 | + database = VuforiaDatabase() |
| 62 | + mock.add_database(database=database) |
| 63 | + vws_client = VWS( |
| 64 | + server_access_key=database.server_access_key, |
| 65 | + server_secret_key=database.server_secret_key, |
| 66 | + ) |
| 67 | + |
| 68 | + target_id = vws_client.add_target( |
| 69 | + name='x', |
| 70 | + width=1, |
| 71 | + image=high_quality_image, |
| 72 | + ) |
| 73 | + |
| 74 | + vws_client.wait_for_target_processed(target_id=target_id) |
| 75 | + |
| 76 | + cloud_reco_client = CloudRecoService( |
| 77 | + client_access_key=database.client_access_key, |
| 78 | + client_secret_key=database.client_secret_key, |
| 79 | + base_vwq_url=base_vwq_url, |
| 80 | + ) |
| 81 | + |
| 82 | + [match] = cloud_reco_client.query(image=high_quality_image) |
| 83 | + assert match['target_id'] == target_id |
| 84 | + |
| 85 | + |
46 | 86 | class TestMaxNumResults: |
47 | 87 | """ |
48 | 88 | Tests for the ``max_num_results`` parameter of ``query``. |
|
0 commit comments