vws-test-fixtures

pytest fixtures for testing tools with the Vuforia Web Services (VWS) API.

Installation

pip install vws-test-fixtures

This is tested on Python 3.13+.

Example usage

"""Run a test which uses a high quality image."""

import io


def test_high_quality_image(high_quality_image: io.BytesIO) -> None:
    """Test that a high quality image is given."""
    image_file_bytes = high_quality_image.getvalue()
    minimum_image_size = 1000
    assert len(image_file_bytes) >= minimum_image_size

All fixtures

Use the names of the following methods as fixture names.

Fixtures for images.

vws_test_fixtures.images.high_quality_image() BytesIO

An image file which is expected to have a ‘success’ status when added to a target and a high tracking rating.

Historically this image has received a tracking rating of 5 from Vuforia. That observation is not a runtime guarantee: Vuforia’s rating thresholds can change, and this fixture does not contact Vuforia or assert a minimum rating.

That rating is not checked in this package’s CI: Vuforia’s scoring can change. Re-check against a real database when bumping the bundled JPEG.

vws_test_fixtures.images.image_file_failed_state() BytesIO

An image file which is expected to be accepted by the add and update target endpoints, but get a “failed” status.

vws_test_fixtures.images.png_too_large() BytesIO

Return a PNG file which has dimensions which are too large to be added to a Vuforia database.

vws_test_fixtures.images.image_file_success_state_low_rating() BytesIO

An image file which is expected to have a ‘success’ status when added to a target and a low rating after processing.

The image is a small random PNG. A low tracking rating is typical but not guaranteed: Vuforia ratings are nondeterministic and can vary across accounts, regions, and time. This fixture does not contact Vuforia or assert a rating.

vws_test_fixtures.images.corrupted_image_file() BytesIO

An image file which is corrupted.

The file is truncated so Pillow cannot open it. Replacing PNG chunk markers (for example IEND) is not reliable: Pillow may still decode the remaining bytes.

vws_test_fixtures.images.image_files_failed_state(request: FixtureRequest) BytesIO

An image file which is expected to be accepted by the add and update target endpoints, but get a “failed” status.

vws_test_fixtures.images.bad_image_file(request: FixtureRequest) BytesIO

An image file which is expected to cause a BadImage result when an attempt is made to add it to the target database.

VWS accepts PNG and JPEG in RGB or greyscale. BMP is used for the unsupported-format case because Pillow writes it reliably across platforms, unlike TIFF.

vws_test_fixtures.images.different_high_quality_image() BytesIO

An image file which is expected to have a ‘success’ status when added to a target and a high tracking rating.

This is necessarily different to high_quality_image. Like high_quality_image, the tracking rating is not verified in CI against live Vuforia thresholds.

vws_test_fixtures.images.high_quality_image_path(high_quality_image: BytesIO, tmp_path: Path) Path

Write high_quality_image to a temporary file and return its path.

Useful for CLI and other APIs that require a filesystem path.

vws_test_fixtures.images.different_high_quality_image_path(different_high_quality_image: BytesIO, tmp_path: Path) Path

Write different_high_quality_image bytes to a temporary path.

Useful for CLI and other APIs that require a filesystem path.

vws_test_fixtures.images.empty_file() BytesIO

An empty (zero-byte) file.

vws_test_fixtures.images.grayscale_jpeg() BytesIO

A valid greyscale (mode L) JPEG image file.

vws_test_fixtures.images.rgba_png() BytesIO

A PNG image in RGBA mode with some transparent pixels.

vws_test_fixtures.images.exif_oriented_jpeg() BytesIO

A JPEG with an EXIF Orientation tag set (Orientation=6).

vws_test_fixtures.images.animated_gif() BytesIO

A multi-frame animated GIF, which Vuforia rejects.

vws_test_fixtures.images.webp_image() BytesIO

A valid WebP image file.

vws_test_fixtures.images.jpeg_too_large() BytesIO

A JPEG larger than the Cloud Recognition 2 MiB query size limit.

vws_test_fixtures.images.pixel_count_too_large() BytesIO

A PNG with more pixels than Vuforia allows, but a small file size.

Uses a single-color greyscale PNG so compression keeps the file small while width * height exceeds _MAX_IMAGE_PIXELS.

6144 * 6144 == _MAX_IMAGE_PIXELS; one extra column exceeds the limit.

vws_test_fixtures.images.png_just_under_max_size() BytesIO

A PNG just under the Target API maximum file size (positive control).

With compress_level=0, an 886x886 RGB PNG is a few kibibytes under VWS_MAX_IMAGE_FILE_SIZE regardless of pixel content.

Fixtures for application metadata.

vws_test_fixtures.metadata.application_metadata_near_size_limit() str

Base64-encoded application metadata near the VWS decoded size limit.

The decoded payload is exactly 1024 * 1024 - 1 bytes, which is the maximum accepted by Vuforia. The returned value is suitable for the application_metadata request field.

Reference