Skip to main content

Vedro D42 Validator

Codecov PyPI PyPI - Downloads Python Version

This plugin integrates d42 schema validation into the Vedro testing framework, providing enhanced schema validation and error handling capabilities during test execution.

Installation

Quick

For a quick installation, you can use a plugin manager as follows:

$ vedro plugin install vedro-d42-validator

Manual

To install manually, follow these steps:

  1. Install the package using pip:
$ pip3 install vedro-d42-validator
  1. Next, activate the plugin in your vedro.cfg.py configuration file:
# ./vedro.cfg.py
import vedro
import vedro_d42_validator

class Config(vedro.Config):

    class Plugins(vedro.Config.Plugins):

        class D42Validator(vedro_d42_validator.D42Validator):
            enabled = True

Usage

Here is an example scenario demonstrating how to decode a base64 encoded string:

# ./scenarios/decode_base64_encoded_string.py
import vedro
from base64 import b64decode
from d42 import schema

class Scenario(vedro.Scenario):
    subject = "decode base64 encoded string"

    def given(self):
        self.encoded = "Y3VjdW1iZXI="

    def when(self):
        self.result = {
            "result": b64decode(self.encoded)
        }

    def then(self):
        assert self.result == schema.dict({
            "result": schema.bytes(b"banana")
        })

Run the test using the command:

$ vedro run

If the expected and actual results don't match, a ValidationException will be raised, as illustrated below:

ValidationException:
 - Value <class 'bytes'> at _['result'] must be equal to b'banana', but b'cucumber' given

Release files for vedro-d42-validator 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vedro-d42-validator 1.4.0
File Size Uploaded
vedro_d42_validator-1.4.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vedro-d42-validator 1.4.0
File Interpreter ABI Platform
vedro_d42_validator-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / vedro_d42_validator-1.4.0.tar.gz

Download URL vedro_d42_validator-1.4.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f3ce5ccd2dec9eb9635a9ff282093353fafe671bf2166931dfdda4da19a2aa5e
BLAKE2b-256 checksum
How to use checksums
b8774ea21d55fec3b3637c547402068e1b240c9c918508df892f96996e638f3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / vedro_d42_validator-1.4.0-py3-none-any.whl

Download URL vedro_d42_validator-1.4.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17c6be29a4c4f7c0a9b413204258af648116bfb4a0685f70f591c53a4bb2a9c2
BLAKE2b-256 checksum
How to use checksums
b0a457bc0387c76fa8700739a9b21f7d630cea95a974f0e23bae77129ae13153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page