Validator plugin for the Vedro testing framework
Project description
Vedro Valera Validator
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:
- Install the package using pip:
$ pip3 install vedro-valera-validator
- 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
Built Distribution
Close
Hashes for vedro-valera-validator-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7bd15697470b9d71217cc186aaf181550cb45ff2652aaf329e13beb66b8b220 |
|
MD5 | b9cb030923b91c5bc7d1da879ffb219e |
|
BLAKE2b-256 | 4ba5431c9bdf1c24cf713f2b9c449a370008a537093752599458efa08395c49f |
Close
Hashes for vedro_valera_validator-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3a90bc856bba5ff31b020fdf0e8f96df5d58062bd80d5aa931620600b7ebd6b |
|
MD5 | 3e1d7ef9b307c12648e7bc20aee77cb0 |
|
BLAKE2b-256 | f448fd1aedc7241db67f1ad6705f9e2ee33bfaf4b13ef3b4269d00bd3686fdfd |