vws-python-mock¶
Mocking calls made to Vuforia¶
$ pip install vws-python-mock
This requires Python 3.14+.
MockVWS intercepts requests to Vuforia made with requests, httpx or HTTPX2.
"""Make a request to the Vuforia Web Services API mock."""
import requests
from mock_vws import MockVWS
from mock_vws.database import CloudDatabase
with MockVWS() as mock:
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
_ = requests.get(url="https://vws.vuforia.com/summary", timeout=30)
By default, an exception will be raised if any requests to unmocked addresses are made.
A MockVWS instance can also decorate a function:
"""Make a request to the Vuforia mock from a decorated function."""
import requests
from mock_vws import MockVWS
from mock_vws.database import CloudDatabase
mock = MockVWS()
mock.add_cloud_database(cloud_database=CloudDatabase())
@mock
def get_summary() -> None:
"""Make a request which uses the Vuforia mock."""
_ = requests.get(url="https://vws.vuforia.com/summary", timeout=30)
get_summary()
Each call of a decorated function gets its own databases and targets, so decorated functions do not affect each other.
A with block, by contrast, shares one set of databases and targets with every other use of the same instance.
See API Reference for details of what can be changed and how.
MockVWS also intercepts requests made with httpx.
"""Make a request to the Vuforia Web Services API mock using httpx."""
import httpx
from mock_vws import MockVWS
from mock_vws.database import CloudDatabase
with MockVWS() as mock:
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
_ = httpx.get(url="https://vws.vuforia.com/summary", timeout=30)
MockVWS also intercepts requests made with HTTPX2, with no need for httpx2.alias_httpx().
"""Make a request to the Vuforia Web Services API mock using httpx2."""
import httpx2
from mock_vws import MockVWS
from mock_vws.database import CloudDatabase
with MockVWS() as mock:
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
_ = httpx2.get(url="https://vws.vuforia.com/summary", timeout=30)
Asynchronous httpx and HTTPX2 clients are intercepted as well.
Using Docker to mock calls to Vuforia from any language¶
It is possible run a Mock VWS instance using Docker containers.
This allows you to run tests against a mock VWS instance regardless of the language or tooling you are using.
See Running a server with Docker for how to do this.
Reference¶
- Installation
- Getting started
- Running a server with Docker
- API Reference
MockVWSMissingSchemeErrorCloudQueryFailureResponseModelTargetFailureResponseModelTargetRequestVuMarkGenerationFailureModelTargetGenerationFailureModelTargetGenerationWarningmock_vws.model_target.JSONValueCloudDatabaseCloudDatabase.database_idCloudDatabase.database_nameCloudDatabase.server_access_keyCloudDatabase.server_secret_keyCloudDatabase.client_access_keyCloudDatabase.client_secret_keyCloudDatabase.targetsCloudDatabase.stateCloudDatabase.database_typeCloudDatabase.request_quotaCloudDatabase.reco_thresholdCloudDatabase.current_month_recosCloudDatabase.previous_month_recosCloudDatabase.total_recosCloudDatabase.target_quotaCloudDatabase.requests_per_second_limitCloudDatabase.request_rate_limits
VuMarkDatabaseRequestRateLimitRequestRateLimitsRateLimitedEndpointDOCUMENTED_REQUEST_RATE_LIMITSStatesDatabaseTypeImageTargetVuMarkTarget- Image matchers
- Target raters
- Differences between the mock and the real Vuforia Web Services
- Image matching
- Speed and summary accuracy
- Image quality and ratings
- Result ordering
- Matching recently deleted targets
- Accepted date formats for the Query API
- Unknown fields in Query API requests
- Targets stuck in processing
- Database summary quotas
transfer-encodingheadersContent-Encodingheadersx-aws-regionheaders- NGINX Error cases
- Result codes
- Request quota exhaustion
- Request rate limits
- Configurable Cloud Query failures
- Configurable Model Target failures
- Other configurable result codes
Content-Lengthheaders- VuMark instance images
- Model Target datasets
- Reco counts reports
- Paths which the mock does not serve
- Header cases
- Unverified behavior
- Categories
- Request quota exhaustion
- A suspended database
- Additional result codes
GET /targetsfor very large databases- The order of reco counts report rows
- Recognition counts in the target summary report
- Processing images in the database summary
- VuMark instance generation for a processing target
- Model Target generation failures
- Model Target generation warnings
- The name of a failed Model Target dataset
- Malformed State-Based configuration documents
- The exhausted training allowance response
- Signed Model Target dataset creation
- OAuth2 client-credential management
- Versioning, Support and API Stability
- Contributing to vws-python-mock