Skip to content

Latest commit

 

History

History
99 lines (63 loc) · 3.08 KB

File metadata and controls

99 lines (63 loc) · 3.08 KB

Build Status PyPI

VWS Mock

Mock for the Vuforia Web Services (VWS) API, the Vuforia Web Query API, and the Model Target Web API.

MockVWS intercepts requests made with requests, httpx or HTTPX2.

pip install vws-python-mock

This requires Python 3.14+.

"""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)

MockVWS also intercepts httpx requests:

"""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 HTTPX2 requests, 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.

By default, an exception will be raised if any requests to unmocked addresses are made.

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 the the instructions for how to do this.

See the full documentation. This includes details on how to use the mock, options, and details of the differences between the mock and the real Vuforia Web Services.