robotframework-tags-parameters


Namerobotframework-tags-parameters JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/LeConTesteur/robotframework-tags-parameters
SummaryCan use and parse parameters from robotframework test tags
upload_time2023-09-21 18:52:07
maintainer
docs_urlNone
authorLeConTesteur
requires_python>=3.8
license
keywords robotframework tags argparse parsing jsonschema data validation validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # robotframework-tags-parameters
![build](https://github.com/LeConTesteur/robotframework-tags-parameters/actions/workflows/build.yml/badge.svg)


## Description

This project want simplify the complexity of initialisation and test by send
data with tag.

This project can convert robotframework tag to dictionary. For this, the project
use jsonschema for declare and annotate tag.

### Example

```robotframework
*** Setting ***
Library    TagsParameters
Test Setup    Generic Test Setup


*** Test Case ***
Test1
    [Tags]    foo    bar    no-reset    name:FOO
    No Operation

Test2
    [Tags]    reset    name:BAR
    No Operation

Test3
    [Tags]    foo    bar
    No Operation

*** Keyword ***
Generic Test Setup
    ${result}=    Convert Tags To Dict    ${CURDIR}/schema_file.json
    Run Keyword If    ${result.foo}    Keyword1
    Run Keyword If    "${result.name}" == "BAR"    Keyword2
    ...
```

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.

```bash
pip install robotframework-tags-parameters
```

## Usage

Import the library into you project

```robotframework
*** Setting ***
Library    TagsParameters
Library    Collections


*** Test Case ***
Test
    [Tags]    foo    bar    no-reset    name:FOO
    ${result}=    Convert Tags To Dict    ${CURDIR}/schema_file.json
    Log    ${result}
    Dictionary Should Contain Item    ${result}     foo    ${True}
    Dictionary Should Contain Item    ${result}     name    FOO
    Dictionary Should Contain Item    ${result}     reset    ${False}
```

Use the json schema for description tags structure:
```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean"
    },
    "name": {
      "type": "string"
    },
    "reset": {
      "type": "boolean",
      "default": true,
      "false-prefix": "no"
    }
  }
}
```

## Tags schema

### Boolean

Simple boolean can be declared with the next jsonschema. By default **foo** is *false*:

```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean"
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
True Foo
    [Tags]    foo
    Should Be Equal   ${result.foo}     ${True}

Default Tags
    Should Be Equal   ${result.foo}     ${False}
```

If you want by default, *true* boolean,you can use **default** attribute.
For declare *false* with tag, you need use **false-prefix** attribute.
**false-prefix** can be take anybody value.
```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean",
      "default": false,
      "false-prefix": "no"
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
False Foo
    [Tags]    no-foo
    Should Be Equal   ${result.foo}     ${False}

True Foo
    [Tags]    foo
    Should Be Equal   ${result.foo}     ${True}

Default Tags
    Should Be Equal   ${result.foo}     ${True}
```

You can change too, the prefix for *true* value with **true-prefix** attribute.
**true-prefix** can be take anybody value.
```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean",
      "true-prefix": "with",
      "false-prefix": "without"
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
False Foo
    [Tags]    without-foo
    Should Be Equal   ${result.foo}     ${False}

True Foo
    [Tags]    with-foo
    Should Be Equal   ${result.foo}     ${True}

Default Tags
    Should Be Equal   ${result.foo}     ${False}
```

### String

Simple string can be declared with the next jsonschema. By default **foo** is *None*:

```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "anyOf": [
        {"type": "string"},
        {"type": "null"},
      ]
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
Tag Foo with BAR value
    [Tags]    foo:BAR
    Should Be Equal   ${result.foo}     BAR

Default Tags
    Should Be Equal   ${result.foo}     ${{None}}
```

You can use too a **type checking** as like:

```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "string",
      "maxLength": 3
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
Tag Foo with BAR value
    [Tags]    foo:BAR
    Should Be Equal   ${result.foo}     ${BAR}

Tag Foo with BAAR value
    [Tags]    foo:BAAR
    [Documentation]  Validation Error is throw

```


### Integer

Simple string can be declared with the next jsonschema.:

```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "integer",
      "default": "0"
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
Tag Foo
    [Tags]    foo:5
    Should Be Equal   ${result.foo}     ${5}

Default Tags
    Should Be Equal   ${result.foo}     ${0}
```

### Default Value

Default value can be declared with the next jsonschema. By default **foo** is *${EMPTY}*:

```json
{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "string",
      "default": ""
    }
  }
}
```
For set **foo** :
```robotframework
*** Test Case ***
Tag Foo with BAR value
    [Tags]    foo:BAR
    Should Be Equal   ${result.foo}     BAR

Default Tags
    Should Be Equal   ${result.foo}     ${EMPTY}
```

## JsonSchema

For more explication into jsonschema, see [https://json-schema.org/](https://json-schema.org/)
You can too see [argparse-from-jsonschema](https://github.com/LeConTesteur/argparse-from-jsonschema)

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Tests

Run tests with tox command :

```bash
tox
tox -e testsacc
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LeConTesteur/robotframework-tags-parameters",
    "name": "robotframework-tags-parameters",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "robotframework,tags,argparse,parsing,jsonschema,data validation,validation",
    "author": "LeConTesteur",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/7b/2c/62562494169f5553e093b5a74c3bd71fdfec657727a6916e63c844bbe167/robotframework-tags-parameters-0.0.4.tar.gz",
    "platform": null,
    "description": "# robotframework-tags-parameters\n![build](https://github.com/LeConTesteur/robotframework-tags-parameters/actions/workflows/build.yml/badge.svg)\n\n\n## Description\n\nThis project want simplify the complexity of initialisation and test by send\ndata with tag.\n\nThis project can convert robotframework tag to dictionary. For this, the project\nuse jsonschema for declare and annotate tag.\n\n### Example\n\n```robotframework\n*** Setting ***\nLibrary    TagsParameters\nTest Setup    Generic Test Setup\n\n\n*** Test Case ***\nTest1\n    [Tags]    foo    bar    no-reset    name:FOO\n    No Operation\n\nTest2\n    [Tags]    reset    name:BAR\n    No Operation\n\nTest3\n    [Tags]    foo    bar\n    No Operation\n\n*** Keyword ***\nGeneric Test Setup\n    ${result}=    Convert Tags To Dict    ${CURDIR}/schema_file.json\n    Run Keyword If    ${result.foo}    Keyword1\n    Run Keyword If    \"${result.name}\" == \"BAR\"    Keyword2\n    ...\n```\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.\n\n```bash\npip install robotframework-tags-parameters\n```\n\n## Usage\n\nImport the library into you project\n\n```robotframework\n*** Setting ***\nLibrary    TagsParameters\nLibrary    Collections\n\n\n*** Test Case ***\nTest\n    [Tags]    foo    bar    no-reset    name:FOO\n    ${result}=    Convert Tags To Dict    ${CURDIR}/schema_file.json\n    Log    ${result}\n    Dictionary Should Contain Item    ${result}     foo    ${True}\n    Dictionary Should Contain Item    ${result}     name    FOO\n    Dictionary Should Contain Item    ${result}     reset    ${False}\n```\n\nUse the json schema for description tags structure:\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"boolean\"\n    },\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"reset\": {\n      \"type\": \"boolean\",\n      \"default\": true,\n      \"false-prefix\": \"no\"\n    }\n  }\n}\n```\n\n## Tags schema\n\n### Boolean\n\nSimple boolean can be declared with the next jsonschema. By default **foo** is *false*:\n\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"boolean\"\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nTrue Foo\n    [Tags]    foo\n    Should Be Equal   ${result.foo}     ${True}\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${False}\n```\n\nIf you want by default, *true* boolean,you can use **default** attribute.\nFor declare *false* with tag, you need use **false-prefix** attribute.\n**false-prefix** can be take anybody value.\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"boolean\",\n      \"default\": false,\n      \"false-prefix\": \"no\"\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nFalse Foo\n    [Tags]    no-foo\n    Should Be Equal   ${result.foo}     ${False}\n\nTrue Foo\n    [Tags]    foo\n    Should Be Equal   ${result.foo}     ${True}\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${True}\n```\n\nYou can change too, the prefix for *true* value with **true-prefix** attribute.\n**true-prefix** can be take anybody value.\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"boolean\",\n      \"true-prefix\": \"with\",\n      \"false-prefix\": \"without\"\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nFalse Foo\n    [Tags]    without-foo\n    Should Be Equal   ${result.foo}     ${False}\n\nTrue Foo\n    [Tags]    with-foo\n    Should Be Equal   ${result.foo}     ${True}\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${False}\n```\n\n### String\n\nSimple string can be declared with the next jsonschema. By default **foo** is *None*:\n\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"anyOf\": [\n        {\"type\": \"string\"},\n        {\"type\": \"null\"},\n      ]\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nTag Foo with BAR value\n    [Tags]    foo:BAR\n    Should Be Equal   ${result.foo}     BAR\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${{None}}\n```\n\nYou can use too a **type checking** as like:\n\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"string\",\n      \"maxLength\": 3\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nTag Foo with BAR value\n    [Tags]    foo:BAR\n    Should Be Equal   ${result.foo}     ${BAR}\n\nTag Foo with BAAR value\n    [Tags]    foo:BAAR\n    [Documentation]  Validation Error is throw\n\n```\n\n\n### Integer\n\nSimple string can be declared with the next jsonschema.:\n\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"integer\",\n      \"default\": \"0\"\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nTag Foo\n    [Tags]    foo:5\n    Should Be Equal   ${result.foo}     ${5}\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${0}\n```\n\n### Default Value\n\nDefault value can be declared with the next jsonschema. By default **foo** is *${EMPTY}*:\n\n```json\n{\n  \"description\": \"My Tags\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"string\",\n      \"default\": \"\"\n    }\n  }\n}\n```\nFor set **foo** :\n```robotframework\n*** Test Case ***\nTag Foo with BAR value\n    [Tags]    foo:BAR\n    Should Be Equal   ${result.foo}     BAR\n\nDefault Tags\n    Should Be Equal   ${result.foo}     ${EMPTY}\n```\n\n## JsonSchema\n\nFor more explication into jsonschema, see [https://json-schema.org/](https://json-schema.org/)\nYou can too see [argparse-from-jsonschema](https://github.com/LeConTesteur/argparse-from-jsonschema)\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Tests\n\nRun tests with tox command :\n\n```bash\ntox\ntox -e testsacc\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Can use and parse parameters from robotframework test tags",
    "version": "0.0.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/LeConTesteur/robotframework-tags-parameters/issues",
        "Homepage": "https://github.com/LeConTesteur/robotframework-tags-parameters"
    },
    "split_keywords": [
        "robotframework",
        "tags",
        "argparse",
        "parsing",
        "jsonschema",
        "data validation",
        "validation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "919add88e84a1e0b334d06b2059a42f9d794ae7f1ac5ab52a78848ca24ed26b0",
                "md5": "f03482ba03d7062deb60e60cb6f50254",
                "sha256": "b9bc7382365ad8d6faf750ca36de2cf5460c874cdaf412b430f2f327c9ab95e8"
            },
            "downloads": -1,
            "filename": "robotframework_tags_parameters-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f03482ba03d7062deb60e60cb6f50254",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4565,
            "upload_time": "2023-09-21T18:52:05",
            "upload_time_iso_8601": "2023-09-21T18:52:05.607474Z",
            "url": "https://files.pythonhosted.org/packages/91/9a/dd88e84a1e0b334d06b2059a42f9d794ae7f1ac5ab52a78848ca24ed26b0/robotframework_tags_parameters-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b2c62562494169f5553e093b5a74c3bd71fdfec657727a6916e63c844bbe167",
                "md5": "2b23af263462f2f7d2ff245bc0194833",
                "sha256": "05e6f9eeae7e01a8fe77e703401e51c1209e2e993c98ef1a2d344b9156e7bfbd"
            },
            "downloads": -1,
            "filename": "robotframework-tags-parameters-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2b23af263462f2f7d2ff245bc0194833",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5097,
            "upload_time": "2023-09-21T18:52:07",
            "upload_time_iso_8601": "2023-09-21T18:52:07.030045Z",
            "url": "https://files.pythonhosted.org/packages/7b/2c/62562494169f5553e093b5a74c3bd71fdfec657727a6916e63c844bbe167/robotframework-tags-parameters-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-21 18:52:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LeConTesteur",
    "github_project": "robotframework-tags-parameters",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "robotframework-tags-parameters"
}
        
Elapsed time: 0.11400s