Skip to main content

Vedro plugin for integrating d42 schema validation

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vedro_d42_validator-1.3.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vedro_d42_validator-1.3.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file vedro_d42_validator-1.3.0.tar.gz.

File metadata

  • Download URL: vedro_d42_validator-1.3.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for vedro_d42_validator-1.3.0.tar.gz
Algorithm Hash digest
SHA256 15d43385ab9dce4d1dc7c62a4031b06c6c8d29214e2282b922bef3413b2904dd
MD5 a60e73324d5d2f347a2c2fd127d0115a
BLAKE2b-256 f704fb3f98329d5d09b864dfba0fb25f2a0c7438c127154c309f0bb79893c01f

See more details on using hashes here.

File details

Details for the file vedro_d42_validator-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vedro_d42_validator-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80d9adfcc4c9ee55d1fc32a20d9a453b8f9d920d43a8ac661c6fa91f10e3695c
MD5 91285c07a2a30224426d5eb7be1e85d5
BLAKE2b-256 bf3114b12da39ef84f2a2be2c89768c584b2a09dc5e0be7649a88e66d307e9a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page