Skip to main content

A natural language testing tool

Project description

Wheatly

About

Wheatly is an approach to developing integration tests in a more natural way. While some technical knowledge is still required, this framework aims to allow for tests to be written using more of a natural language approach while still allowing for the flexibility needed to create robust tests.

Usage

Create some directory you want to store you plugins in (see the plugins directory for examples). The only required plugin is a config.py file which takes the following form:

lexicon = {
    'model': {
        'class': "Model",
        'tokens': [
            'model',
            'models',
        ],
        'actions': {
            'get': [
                'get',
                'gets',
                'getting',
                'got'
            ],
            'delete': [
                'delete',
                'deleted',
                'deleting',
                'deletes'
            ]
        },
        'modifiers': {}
    }
}

Each object in the lexicon variable should correspond to a same name file within the same plugin directory. Each of these files will represent some sort of object you want to work with (or an object to encapsulate various actions). They should take this form (notice that the name of the class matches the lexicon's class field):

import config
import wheatly.utils as utils

class Model:
    def __init__(self):
        self.name = 'model'
        self.tokens = config.lexicon[self.name]['tokens']
        self.actions = config.lexicon[self.name]['actions']
        self.modifiers = config.lexicon[self.name]['modifiers']

    def action_get(self, context, logger, args={}, modifiers=[]):
        # perform get actions for this object
        print('get!')
        # return modified context and success or fail
        return context, True

    def action_delete(self, context, logger, args={}, modifiers=[]):
        # perform delete actions for this object 
        print('delete!')
        # return modified context and success or fail
        return context, True

    def __str__(self):
        return f'{self.name}()'

    def __repr__(self):
        return f'{self.name}()'

After writing any modules you want to use, create a test file with the following form:

tests:
  example:
    # Execute some HTTP request
    - curl:
        host: https://pypi.org
        path: project/calligraphy-scripting
        method: get
        # Set this to a dictionary if you want to send some JSON data alone with the request
        data: ~
        response_type: html
    # Execute a wait with the duration in seconds
    - wait: 5
    # Text of what to do
    - get a model:
        # Optional dictionary for any arguments you want to pass along
        foo: bar

Currently you can use curl and wait to run custom globally available actions. You can also write natural language actions which Wheatly will parse and run via the plugins you wrote.

To run your test, first generate the test JSON via:

python src/main.py generate -p ./plugins -i examples/example.yaml -o examples/example.json

You can then run the generated test JSON via:

python src/main.py run -p ./plugins -i examples/example.json

TODO:

  • Add summary command

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

wheatly-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

wheatly-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file wheatly-0.1.0.tar.gz.

File metadata

  • Download URL: wheatly-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.0 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for wheatly-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ea23fbe7f4086a1c2c758ccb2de48d7b4a1eedc43afe02d314d8db305db693a
MD5 04e7fb1f0ff4827ebcb0f2df80edd764
BLAKE2b-256 efb113cdb8744071aa97fc4d6530a01f2e5774eaaf22cf854738832a75d20312

See more details on using hashes here.

File details

Details for the file wheatly-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wheatly-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.0 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for wheatly-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7703ab24c9c796217993501229a3e85f7649951b1a05310d7259aa76608391c7
MD5 6d43d3e061fd397a4bb5ab37b27cce4b
BLAKE2b-256 0f1d009b10c1dc3751d802bdb39154e01afd3080dec70092ab8ae5edd4484251

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