Skip to main content

robotframework-tags-parameters

build

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

*** 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 to install foobar.

pip install robotframework-tags-parameters

Usage

Import the library into you project

*** 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:

{
  "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:

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean"
    }
  }
}

For set foo :

*** 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.

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean",
      "default": false,
      "false-prefix": "no"
    }
  }
}

For set foo :

*** 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.

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "boolean",
      "true-prefix": "with",
      "false-prefix": "without"
    }
  }
}

For set foo :

*** 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:

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "anyOf": [
        {"type": "string"},
        {"type": "null"},
      ]
    }
  }
}

For set foo :

*** 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:

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "string",
      "maxLength": 3
    }
  }
}

For set foo :

*** 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.:

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "integer",
      "default": "0"
    }
  }
}

For set foo :

*** 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}:

{
  "description": "My Tags",
  "type": "object",
  "properties": {
    "foo": {
      "type": "string",
      "default": ""
    }
  }
}

For set foo :

*** 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/ You can too see 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 :

tox
tox -e testsacc

Metadata

Release files for robotframework-tags-parameters 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotframework-tags-parameters 0.0.4
File Size Uploaded
robotframework-tags-parameters-0.0.4.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for robotframework-tags-parameters 0.0.4
File Interpreter ABI Platform
robotframework_tags_parameters-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / robotframework-tags-parameters-0.0.4.tar.gz

Download URL robotframework-tags-parameters-0.0.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
05e6f9eeae7e01a8fe77e703401e51c1209e2e993c98ef1a2d344b9156e7bfbd
BLAKE2b-256 checksum
How to use checksums
7b2c62562494169f5553e093b5a74c3bd71fdfec657727a6916e63c844bbe167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / robotframework_tags_parameters-0.0.4-py3-none-any.whl

Download URL robotframework_tags_parameters-0.0.4-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9bc7382365ad8d6faf750ca36de2cf5460c874cdaf412b430f2f327c9ab95e8
BLAKE2b-256 checksum
How to use checksums
919add88e84a1e0b334d06b2059a42f9d794ae7f1ac5ab52a78848ca24ed26b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page