Skip to main content

Validator plugin for Vedro testing framework

Project description

Vedro Valera Validator

Codecov PyPI PyPI - Downloads Python Version

vedro-valera-validator is a plugin for the Vedro framework that utilizes the valera validator, a package designed for data validation based on d42 (district42) schemas. Valera validator provides a simple yet powerful approach to ensure your data aligns perfectly with your expectations.

Installation

Quick

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

$ vedro plugin install vedro-valera-validator

Manual

To install manually, follow these steps:

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

class Config(vedro.Config):

    class Plugins(vedro.Config.Plugins):

        class ValeraValidator(vedro_valera_validator.ValeraValidator):
            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

Additional Resources

For a detailed guide and further information, check out the documentation.

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_valera_validator-1.2.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

vedro_valera_validator-1.2.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file vedro_valera_validator-1.2.0.tar.gz.

File metadata

File hashes

Hashes for vedro_valera_validator-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ed09b79a48b0489a265e40ee98a77856145f08d94dbe839db2031ab64425fd20
MD5 01d0eb9e6fb7d377b4d84f023873093b
BLAKE2b-256 01401a78b7012ede515a5548ff6b5d0296f996f5faf5f1c4871faff47d34bcc3

See more details on using hashes here.

File details

Details for the file vedro_valera_validator-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vedro_valera_validator-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ec3027bb4f0806efa298be936226c0b8856615a3320695156512c454b0ea642
MD5 5bacea13f6555c59edaaa79ea848ced6
BLAKE2b-256 3a2d686ff614938ba57ba12c31c52727106cbf70dcd96af98f6b0fc8be5ecc26

See more details on using hashes here.

Supported by

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