Skip to main content

Validator plugin for the Vedro testing framework

Project description

Vedro Valera Validator

Codecov PyPI PyPI - Downloads Python Version

Validator plugin for the Vedro testing framework.

How to Install

Quick

For a quick installation, you can use a plugin manager like so:

$ 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. Then, enable the plugin in the 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

How to Use

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 -vv

If the expected and actual results do not match, a ValidationException will be thrown, as shown below:

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

Further Reading

For comprehensive guidance and more information, refer to the official 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.1.1.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

vedro_valera_validator-1.1.1-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

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