robotframework-assertion-engine


Namerobotframework-assertion-engine JSON
Version 3.0.3 PyPI version JSON
download
home_pagehttps://github.com/MarketSquare/AssertionEngine
SummaryGeneric way to create meaningful and easy to use assertions for the Robot Framework libraries.
upload_time2023-11-21 19:20:22
maintainer
docs_urlNone
authorTatu Aalto
requires_python>=3.8.1,<4.0
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Assertion Engine
================

Generic way to create meaningful and easy to use assertions for the `Robot Framework`_
libraries. This tools is spin off from `Browser library`_ project, where the Assertion
Engine was developed as part of the of library.

.. image:: https://github.com/MarketSquare/AssertionEngine/actions/workflows/on-push.yml/badge.svg
   :target: https://github.com/MarketSquare/AssertionEngine
.. image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
   :target: https://opensource.org/licenses/Apache-2.0

Supported Assertions
--------------------

Currently supported assertion operators are:

+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| Operator | Alternative Operators     | Description                                                                        | Validate Equivalent              |
+==========+===========================+====================================================================================+==================================+
| ==       | equal, equals, should be  | Checks if returned value is equal to expected value.                               | value == expected                |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| !=       | inequal, should not be    | Checks if returned value is not equal to expected value.                           | value != expected                |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| >        | greater than              | Checks if returned value is greater than expected value.                           | value > expected                 |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| >=       |                           | Checks if returned value is greater than or equal to expected value.               | value >= expected                |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| <        | less than                 | Checks if returned value is less than expected value.                              | value < expected                 |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| <=       |                           | Checks if returned value is less than or equal to expected value.                  | value <= expected                |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| \*=      | contains                  | Checks if returned value contains expected value as substring.                     | expected in value                |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
|          | not contains              | Checks if returned value does not contain expected value as substring.             | expected not in value            |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| ^=       | should start with, starts | Checks if returned value starts with expected value.                               | re.search(f"^{expected}", value) |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| $=       | should end with, ends     | Checks if returned value ends with expected value.                                 | re.search(f"{expected}$", value) |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| matches  |                           | Checks if given RegEx matches minimum once in returned value.                      | re.search(expected, value)       |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| validate |                           | Checks if given Python expression evaluates to True.                               |                                  |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+
| evaluate |  then                     | When using this operator, the keyword does return the evaluated Python expression. |                                  |
+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+

Supported formatters:

+-------------------+------------------------------------------------------------+
| Formatter         | Description                                                |
+===================+============================================================+
| normalize spaces  | Substitutes multiple spaces to single space from the value |
+-------------------+------------------------------------------------------------+
| strip             | Removes spaces from the beginning and end of the value     |
+-------------------+------------------------------------------------------------+
| apply to expected | Applies rules also for the expected value                  |
+-------------------+------------------------------------------------------------+
| case insensitive  | Converts value to lower case                               |
+-------------------+------------------------------------------------------------+

Usage
-----
When library developers wants to do an assertion inline with the keyword call, then AssertionEngine provides
automatic validation within single keyword call. Keyword method should get value, example from page, database
or from anything which the library interacts and then use `verify_assertion` method from AssertionEngine to
perform the validation. The `verify_assertion` methods needs three things to perform the assertion:
`value` from the system, `assertion_operator` how  the validation is performed and `assertion_expected` which
represent the expected value. It is also possible to provide custom error message and prefix the default error
message.

Example library can contain keyword::

    def keyword(
        arg_to_get_value: str,
        assertion_operator: Optional[AssertionOperator] = None,
        assertion_expected: Any = None,
        message: str = None,
    ):
        value = method_to_get_value(arg_to_get_value)
        return verify_assertion(
            value,
            assertion_operator,
            assertion_expected,
            "Prefix message",
            message,
        )

AssertionEngine provides an interface to define scope for the formatters, but because scoping is a library
specific implementation, it is up to the library to decide how scoping is actually implemented. AssertionEngine
Formatter class is an `ABC <https://docs.python.org/3/library/abc.html>`_ which provides `get_formatter` and
`set_formatter` interface methods for library developers. The AssertionEngine
`atest <https://github.com/MarketSquare/AssertionEngine/tree/main/atest>`_ libraries has examples how interface
can be implemented in practice.

.. _Robot Framework: http://robotframework.org
.. _Browser library: https://robotframework-browser.org/


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MarketSquare/AssertionEngine",
    "name": "robotframework-assertion-engine",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tatu Aalto",
    "author_email": "aalto.tatu@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/82/6a/64caaaff181a6f56847124a98e029bd91e3479c56f2db2803e3f5e19a8d8/robotframework_assertion_engine-3.0.3.tar.gz",
    "platform": null,
    "description": "Assertion Engine\n================\n\nGeneric way to create meaningful and easy to use assertions for the `Robot Framework`_\nlibraries. This tools is spin off from `Browser library`_ project, where the Assertion\nEngine was developed as part of the of library.\n\n.. image:: https://github.com/MarketSquare/AssertionEngine/actions/workflows/on-push.yml/badge.svg\n   :target: https://github.com/MarketSquare/AssertionEngine\n.. image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg\n   :target: https://opensource.org/licenses/Apache-2.0\n\nSupported Assertions\n--------------------\n\nCurrently supported assertion operators are:\n\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| Operator | Alternative Operators     | Description                                                                        | Validate Equivalent              |\n+==========+===========================+====================================================================================+==================================+\n| ==       | equal, equals, should be  | Checks if returned value is equal to expected value.                               | value == expected                |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| !=       | inequal, should not be    | Checks if returned value is not equal to expected value.                           | value != expected                |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| >        | greater than              | Checks if returned value is greater than expected value.                           | value > expected                 |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| >=       |                           | Checks if returned value is greater than or equal to expected value.               | value >= expected                |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| <        | less than                 | Checks if returned value is less than expected value.                              | value < expected                 |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| <=       |                           | Checks if returned value is less than or equal to expected value.                  | value <= expected                |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| \\*=      | contains                  | Checks if returned value contains expected value as substring.                     | expected in value                |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n|          | not contains              | Checks if returned value does not contain expected value as substring.             | expected not in value            |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| ^=       | should start with, starts | Checks if returned value starts with expected value.                               | re.search(f\"^{expected}\", value) |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| $=       | should end with, ends     | Checks if returned value ends with expected value.                                 | re.search(f\"{expected}$\", value) |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| matches  |                           | Checks if given RegEx matches minimum once in returned value.                      | re.search(expected, value)       |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| validate |                           | Checks if given Python expression evaluates to True.                               |                                  |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n| evaluate |  then                     | When using this operator, the keyword does return the evaluated Python expression. |                                  |\n+----------+---------------------------+------------------------------------------------------------------------------------+----------------------------------+\n\nSupported formatters:\n\n+-------------------+------------------------------------------------------------+\n| Formatter         | Description                                                |\n+===================+============================================================+\n| normalize spaces  | Substitutes multiple spaces to single space from the value |\n+-------------------+------------------------------------------------------------+\n| strip             | Removes spaces from the beginning and end of the value     |\n+-------------------+------------------------------------------------------------+\n| apply to expected | Applies rules also for the expected value                  |\n+-------------------+------------------------------------------------------------+\n| case insensitive  | Converts value to lower case                               |\n+-------------------+------------------------------------------------------------+\n\nUsage\n-----\nWhen library developers wants to do an assertion inline with the keyword call, then AssertionEngine provides\nautomatic validation within single keyword call. Keyword method should get value, example from page, database\nor from anything which the library interacts and then use `verify_assertion` method from AssertionEngine to\nperform the validation. The `verify_assertion` methods needs three things to perform the assertion:\n`value` from the system, `assertion_operator` how  the validation is performed and `assertion_expected` which\nrepresent the expected value. It is also possible to provide custom error message and prefix the default error\nmessage.\n\nExample library can contain keyword::\n\n    def keyword(\n        arg_to_get_value: str,\n        assertion_operator: Optional[AssertionOperator] = None,\n        assertion_expected: Any = None,\n        message: str = None,\n    ):\n        value = method_to_get_value(arg_to_get_value)\n        return verify_assertion(\n            value,\n            assertion_operator,\n            assertion_expected,\n            \"Prefix message\",\n            message,\n        )\n\nAssertionEngine provides an interface to define scope for the formatters, but because scoping is a library\nspecific implementation, it is up to the library to decide how scoping is actually implemented. AssertionEngine\nFormatter class is an `ABC <https://docs.python.org/3/library/abc.html>`_ which provides `get_formatter` and\n`set_formatter` interface methods for library developers. The AssertionEngine\n`atest <https://github.com/MarketSquare/AssertionEngine/tree/main/atest>`_ libraries has examples how interface\ncan be implemented in practice.\n\n.. _Robot Framework: http://robotframework.org\n.. _Browser library: https://robotframework-browser.org/\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Generic way to create meaningful and easy to use assertions for the Robot Framework libraries.",
    "version": "3.0.3",
    "project_urls": {
        "Documentation": "https://github.com/MarketSquare/AssertionEngine/blob/master/README.rst",
        "Homepage": "https://github.com/MarketSquare/AssertionEngine"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "515db160d9a55db18f9847e0cc680012dfab03e9efcebae0a09280d57ae8a6ee",
                "md5": "dd2e6d8af83037b345f2022500947782",
                "sha256": "3cd8962744ea4f307feadd596266c1d563e87b586ed61803c9445295ab15a0cd"
            },
            "downloads": -1,
            "filename": "robotframework_assertion_engine-3.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd2e6d8af83037b345f2022500947782",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 12944,
            "upload_time": "2023-11-21T19:20:20",
            "upload_time_iso_8601": "2023-11-21T19:20:20.251175Z",
            "url": "https://files.pythonhosted.org/packages/51/5d/b160d9a55db18f9847e0cc680012dfab03e9efcebae0a09280d57ae8a6ee/robotframework_assertion_engine-3.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "826a64caaaff181a6f56847124a98e029bd91e3479c56f2db2803e3f5e19a8d8",
                "md5": "7b367ddf2652a0f781e5380884b70737",
                "sha256": "1c608d4c69d96520986a1ddc6def0fc7f7e849520f1e6882a633b51dbb98fd88"
            },
            "downloads": -1,
            "filename": "robotframework_assertion_engine-3.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7b367ddf2652a0f781e5380884b70737",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 11901,
            "upload_time": "2023-11-21T19:20:22",
            "upload_time_iso_8601": "2023-11-21T19:20:22.752497Z",
            "url": "https://files.pythonhosted.org/packages/82/6a/64caaaff181a6f56847124a98e029bd91e3479c56f2db2803e3f5e19a8d8/robotframework_assertion_engine-3.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-21 19:20:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MarketSquare",
    "github_project": "AssertionEngine",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "robotframework-assertion-engine"
}
        
Elapsed time: 0.43421s