wheatly


Namewheatly JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/jfcarter2358/wheatly
SummaryA natural language testing tool
upload_time2023-04-26 18:18:26
maintainer
docs_urlNone
authorJohn Carter
requires_python>=3.10,<4.0
license
keywords testing natural language
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```python
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):

```python
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:

```yaml
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:

```bash
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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jfcarter2358/wheatly",
    "name": "wheatly",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "testing,natural language",
    "author": "John Carter",
    "author_email": "jfcarter2358@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ef/b1/13cdb8744071aa97fc4d6530a01f2e5774eaaf22cf854738832a75d20312/wheatly-0.1.0.tar.gz",
    "platform": null,
    "description": "# Wheatly\n## About\nWheatly 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.\n\n# Usage\nCreate 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:\n\n```python\nlexicon = {\n    'model': {\n        'class': \"Model\",\n        'tokens': [\n            'model',\n            'models',\n        ],\n        'actions': {\n            'get': [\n                'get',\n                'gets',\n                'getting',\n                'got'\n            ],\n            'delete': [\n                'delete',\n                'deleted',\n                'deleting',\n                'deletes'\n            ]\n        },\n        'modifiers': {}\n    }\n}\n```\n\nEach 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):\n\n```python\nimport config\nimport wheatly.utils as utils\n\nclass Model:\n    def __init__(self):\n        self.name = 'model'\n        self.tokens = config.lexicon[self.name]['tokens']\n        self.actions = config.lexicon[self.name]['actions']\n        self.modifiers = config.lexicon[self.name]['modifiers']\n\n    def action_get(self, context, logger, args={}, modifiers=[]):\n        # perform get actions for this object\n        print('get!')\n        # return modified context and success or fail\n        return context, True\n\n    def action_delete(self, context, logger, args={}, modifiers=[]):\n        # perform delete actions for this object \n        print('delete!')\n        # return modified context and success or fail\n        return context, True\n\n    def __str__(self):\n        return f'{self.name}()'\n\n    def __repr__(self):\n        return f'{self.name}()'\n```\n\nAfter writing any modules you want to use, create a test file with the following form:\n\n```yaml\ntests:\n  example:\n    # Execute some HTTP request\n    - curl:\n        host: https://pypi.org\n        path: project/calligraphy-scripting\n        method: get\n        # Set this to a dictionary if you want to send some JSON data alone with the request\n        data: ~\n        response_type: html\n    # Execute a wait with the duration in seconds\n    - wait: 5\n    # Text of what to do\n    - get a model:\n        # Optional dictionary for any arguments you want to pass along\n        foo: bar\n```\n\nCurrently 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.\n\nTo run your test, first generate the test JSON via:\n\n```bash\npython src/main.py generate -p ./plugins -i examples/example.yaml -o examples/example.json\n```\n\nYou can then run the generated test JSON via:\n\n```\npython src/main.py run -p ./plugins -i examples/example.json\n```\n\n# TODO: \n\n- [ ] Add summary command\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A natural language testing tool",
    "version": "0.1.0",
    "split_keywords": [
        "testing",
        "natural language"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f1d009b10c1dc3751d802bdb39154e01afd3080dec70092ab8ae5edd4484251",
                "md5": "6d43d3e061fd397a4bb5ab37b27cce4b",
                "sha256": "7703ab24c9c796217993501229a3e85f7649951b1a05310d7259aa76608391c7"
            },
            "downloads": -1,
            "filename": "wheatly-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6d43d3e061fd397a4bb5ab37b27cce4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 9176,
            "upload_time": "2023-04-26T18:18:24",
            "upload_time_iso_8601": "2023-04-26T18:18:24.584396Z",
            "url": "https://files.pythonhosted.org/packages/0f/1d/009b10c1dc3751d802bdb39154e01afd3080dec70092ab8ae5edd4484251/wheatly-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efb113cdb8744071aa97fc4d6530a01f2e5774eaaf22cf854738832a75d20312",
                "md5": "04e7fb1f0ff4827ebcb0f2df80edd764",
                "sha256": "1ea23fbe7f4086a1c2c758ccb2de48d7b4a1eedc43afe02d314d8db305db693a"
            },
            "downloads": -1,
            "filename": "wheatly-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "04e7fb1f0ff4827ebcb0f2df80edd764",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 8264,
            "upload_time": "2023-04-26T18:18:26",
            "upload_time_iso_8601": "2023-04-26T18:18:26.584682Z",
            "url": "https://files.pythonhosted.org/packages/ef/b1/13cdb8744071aa97fc4d6530a01f2e5774eaaf22cf854738832a75d20312/wheatly-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-26 18:18:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jfcarter2358",
    "github_project": "wheatly",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wheatly"
}
        
Elapsed time: 0.05793s