From e488e47e82a53a822efd2e6723269f443e10c650 Mon Sep 17 00:00:00 2001 From: touchedthecode Date: Thu, 4 Jan 2024 21:39:02 +0100 Subject: [PATCH] git init --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 158 +++ LICENSE | 201 +++ PipeLibrary/__init__.py | 166 +++ README.md | 79 ++ docs/PipeLibrary.html | 1835 +++++++++++++++++++++++++ poetry.lock | 17 + pyproject.toml | 19 + tests/.DS_Store | Bin 0 -> 6148 bytes tests/01__default.robot | 31 + tests/02__pipe_strategy_prepend.robot | 13 + tests/03__pipe_strategy_append.robot | 10 + tests/04__custom_placeholder.robot | 12 + tests/05__custom_pipe_operator.robot | 7 + tests/06__custom.robot | 12 + tests/__init__.py | 0 tests/keywords.resource | 20 + 17 files changed, 2580 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 PipeLibrary/__init__.py create mode 100644 README.md create mode 100644 docs/PipeLibrary.html create mode 100644 poetry.lock create mode 100644 pyproject.toml create mode 100644 tests/.DS_Store create mode 100644 tests/01__default.robot create mode 100644 tests/02__pipe_strategy_prepend.robot create mode 100644 tests/03__pipe_strategy_append.robot create mode 100644 tests/04__custom_placeholder.robot create mode 100644 tests/05__custom_pipe_operator.robot create mode 100644 tests/06__custom.robot create mode 100644 tests/__init__.py create mode 100644 tests/keywords.resource diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..061a35a37c9c5828df5925c9498e38768fb2bf68 GIT binary patch literal 6148 zcmeHK%}T>S5Z>*NZ7D(y3Oz1(Em(_)#Y>3w1&ruHr6we3FlI}WnnNk%tS{t~_&m<+ zZlJ;7QN+%`?l(I>yO|HNKa4T%EQ2G)EXG(D8X`xfM$laAYM5X|uI5PnJe~Wo^lPU1 znOu6Fc5X4YV}IvtOO;$$*j55;PN`Z4J1 zUU&cC@a%H-9KR&;O%ut1aV5J3OLzxmqoP-Lk;F221Z$a5MiLSO!~iis3~VO@<~->3 zx3hezniwDkeqaFi2LTPyHdts>TL*M_eMWx^5e0O7OCSn^w!uOpctE&L1=OkBJTbUV z2fHwFw!uQ9PG?-L4D*tAkyraK>$o)Dr{5K$U@}9$I+*U%)R@`^c}R(1;iy z2L2fXyft;F4ish1)^FwESu3DDKtsW}0u>O@E0+Km;65@?PVE<{L!51}(1^33U8Muk OML-ck9Wn3=4158IuS+EW literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1eb822 --- /dev/null +++ b/.gitignore @@ -0,0 +1,158 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# Robot framework test result output +log.html +output.xml +report.html \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c61b663 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/PipeLibrary/__init__.py b/PipeLibrary/__init__.py new file mode 100644 index 0000000..f98396e --- /dev/null +++ b/PipeLibrary/__init__.py @@ -0,0 +1,166 @@ +from typing import Literal +from robot.libraries.BuiltIn import BuiltIn, register_run_keyword +from robot.api.deco import keyword, library +from robot.api import logger +import importlib.metadata + + +# Decorator to register a method as a Robot Framework keyword variant. +def run_keyword_variant(resolve): + def decorator(method): + register_run_keyword( + "PipeLibrary", method.__name__, resolve, deprecation_warning=False + ) + return method + + return decorator + + +@library +class PipeLibrary: + """Library implementing a pipe operator for keyword chaining. + + This library enhances keyword chaining capabilities in Robot Framework by introducing a pipe operator, + similar to the one found in functional programming languages. It simplifies the process of passing the + output of one keyword as an input to another, enabling more readable and maintainable test cases. + + = Table of contents = + + %TOC% + + = Usage = + + The PipeLibrary allows chaining multiple Robot Framework keywords using the `>>` pipe operator. + It removes the need for intermediate variables, making the data flow between keywords cleaner and more intuitive. + + = Syntax = + + - `Pipe`: The main keyword of the PipeLibrary. + - `>>`: The pipe operator, used to chain keywords. + - `Placeholder` (`$` by default): Denotes where the output of the previous keyword should be placed in the next keyword's arguments. + + By default, the result of a keyword is used as the first argument of the next keyword, but this can be customized. + + = Example = + + | `Pipe` Get User Id username + | ... >> Fetch User Details + | ... >> Process Data + | ... >> Validate User + | ... >> Log + + = Configuration = + + The library can be initialized with custom settings for `pipe_strategy`, `placeholder`, and `pipe_operator`. + + = Note = + + PipeLibrary does not support keyword syntax highlighting and autocompletion in Robot Framework due to its dynamic nature. + + = Contributions = + + Contributions, bug reports, and suggestions for improvements are welcome. Please visit our GitHub repository. + + """ + + ROBOT_LIBRARY_VERSION = importlib.metadata.version("robotframework-pipe") + ROBOT_LIBRARY_SCOPE = "TEST" + ROBOT_LIBRARY_FORMAT = "reST" + + def __init__( + self, + pipe_strategy: Literal["prepend", "append"] = "prepend", + placeholder: str = "$", + pipe_operator: str = ">>", + ): + """Initializes the PipeLibrary with optional configuration for piping strategy, placeholder, and operator. + + The `pipe_strategy` can be either 'prepend' or 'append', affecting how the piped result is inserted into the arguments of the next keyword. + The `placeholder` is a string used in the arguments of keywords to denote where the piped result should be placed. + The `pipe_operator` is a string used to separate different keywords in a piped sequence. + + Examples: + + | =Setting= | =Value= | =Value= | =Comment= | + | Library | PipeLibrary | | # Default prepend strategy | + | Library | PipeLibrary | append | # Set strategy to append | + """ + self.built_in = BuiltIn() + self.pipe_strategy = pipe_strategy + self.placeholder = placeholder + self.pipe_operator = pipe_operator + + @run_keyword_variant(0) + @keyword + def pipe(self, *keywords): + """Executes a series of Robot Framework keywords in a piped sequence. + + Keywords and their arguments are separated by the `pipe_operator`. The output of each keyword can be passed as input to the next one. + + Example: + + | `Pipe` Get User Id username + | ... >> Fetch User Details + | ... >> Process Data + | ... >> Validate User + | ... >> Log + + The piped result from each keyword is passed according to the `pipe_strategy` and can be explicitly referred to using the `placeholder` (`$` by default). + + Example using the placeholder: + + | `Pipe` Get User Id username + | ... >> Fetch User Details $ + | ... >> Process Data $ + | ... >> Validate User $ + | ... >> Log $ + """ + + # Split the provided keywords and arguments + keyword_calls = self._split_pipe_keywords(keywords) + + # Initial value for the piped result + piped_result = None + + # Execute each keyword in sequence + for kw, args in keyword_calls: + if piped_result is not None: + if self.placeholder in args: + # Replace the placeholder with the piped result + args = [ + piped_result if arg == self.placeholder else arg for arg in args + ] + else: + if self.pipe_strategy == "append": + args.append(piped_result) + else: + args.insert(0, piped_result) + + try: + piped_result = self.built_in.run_keyword(kw, *args) + except Exception as e: + logger.error(f"Error executing keyword '{kw}': {e}") + raise + + return piped_result + + def _split_pipe_keywords(self, keywords): + """Internal method to split the piped keyword sequence into individual keywords and their arguments. + + This method is used by the `pipe` method to process the given sequence of keywords and arguments, + splitting them based on the `pipe_operator`. + + This is an internal utility method and not exposed as a Robot Framework keyword. + """ + split_keywords = [] + current_keyword = [] + for item in keywords: + if item == self.pipe_operator: + if current_keyword: + split_keywords.append((current_keyword[0], current_keyword[1:])) + current_keyword = [] + else: + current_keyword.append(item) + if current_keyword: + split_keywords.append((current_keyword[0], current_keyword[1:])) + return split_keywords diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e86b63 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# robotframework-pipe + +## Introduction + +Pipe is a Robot Framework Library that brings the pipe operator known from functional programming languages into Robot Framework. PipeLibrary is designed to enhance keyword chaining capabilities, it simplifies the process of passing the output of one keyword as an input to another, enabling more readable and maintainable test cases. + +## Installation + +To install PipeLibrary, run the following command: + +```bash +pip install robotframework-pipe +``` + +## Usage + +Here's a basic example to demonstrate the usage of the PipeLibrary: + +```RobotFramework +Complex Operation With Pipe + Pipe Get User Id username + ... >> Fetch User Details + ... >> Process Data + ... >> Validate User + ... >> Log +``` + +Without Pipe, the same example would require intermediate variables: + +```RobotFramework +Complex Operation Without Pipe + ${user_id} = Get User Id username + ${user_details} = Fetch User Details ${user_id} + ${processed_data} = Process Data ${user_details} + ${status} = Validate User ${processed_data} + Log ${status} +``` + +The PipeLibrary simplifies the process by removing the need for intermediate variables and making the flow of data between keywords more intuitive and cleaner. + +### Syntax Explanation + +- `Pipe`: The main keyword of the PipeLibrary. +- `>>`: The pipe operator, used to chain keywords. +- `Placeholder`: A symbol (default `$`) used to denote where the output of the previous keyword should be placed in the next keyword's argument list. This is optional. + +By default, the result of the keyword is used as the _first_ argument of the next keyword. You can use the Placeholder to explicitly set the argument or import the PipeLibrary with the argument `pipe_strategy=append` to use the result as the _last_ argument by default. + +## Examples + +You can find more examples in the `/tests` directory. + +### Using Placeholder + +```RobotFramework +My Test Case + Pipe Sum 1 2 + ... >> Subtract 4 $ + ... >> Should be Equal As Integers 1 +``` + +In this example, `$` is replaced with the result of Sum, so Subtract is called as `Subtract 4 3`. + +## Configuration + +You can initialize the library with custom settings: + +```RobotFramework +*** Settings *** +Library PipeLibrary pipe_strategy=append placeholder=$ pipe_operator=>> +``` + +## Note + +Currently, PipeLibrary does not support keyword syntax highlighting and autocompletion in the Robot Framework environment. This is due to the dynamic nature of the pipe operator and the way arguments are passed between keywords. + +## Contributions + +Contributions to PipeLibrary are welcome! If you have suggestions for improvements or have identified a bug, please feel free to open an issue or submit a pull request on our GitHub repository. diff --git a/docs/PipeLibrary.html b/docs/PipeLibrary.html new file mode 100644 index 0000000..363312b --- /dev/null +++ b/docs/PipeLibrary.html @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Opening library documentation failed

+
    +
  • Verify that you have JavaScript enabled in your browser.
  • +
  • Make sure you are using a modern enough browser. If using Internet Explorer, version 11 is required.
  • +
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..a300b3f --- /dev/null +++ b/poetry.lock @@ -0,0 +1,17 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "robotframework" +version = "5.0.1" +description = "Generic automation framework for acceptance testing and robotic process automation (RPA)" +optional = false +python-versions = ">=3.6" +files = [ + {file = "robotframework-5.0.1-py3-none-any.whl", hash = "sha256:2d2072cf9ec807e820bf27e5f71240e715e37691c9ba930a59a71d5c0fd61998"}, + {file = "robotframework-5.0.1.zip", hash = "sha256:cf5dc59777ed9d8c3e1e91fb4403454890242867735681f22f4f22dbb2a20fc8"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "8781efbe1d609fa3ad8067c7db2a8fdc30f9e84b23c4d06e0ebc232e7561051b" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f3ea58f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "robotframework-pipe" +version = "0.1.0" +description = "Enhance Robot Framework with functional-style keyword chaining. Streamline test cases by piping output of one keyword as input to another, simplifying data flow and readability." +license = "Apache-2.0" +authors = ["touchedthecode "] +readme = "README.md" + +packages = [ + { include = "PipeLibrary" }, +] + +[tool.poetry.dependencies] +python = "^3.8" +robotframework = "^5.0.1" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/tests/.DS_Store b/tests/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..36039f049767df21b7da71c29e0e64195e4c8069 GIT binary patch literal 6148 zcmeHK%Sr=55UhzgL<16UUX=ZU#o)=?8sb6lAou|>8)FPaH{=24wqN2e_m!@cG<}QaJ}_Y7w7UNfm(pi==ny-pm660?*UDP=*Qz7G+bU=lF*sGkmY zdITUg=~m;loF#-41xy0w9yvmDo=Wso7mgUt)9H^wToN$%=;?6b@ZrMDE}T%D&d&Ui zhQlQutv3ZsfwBSz{> Negate >> Double >> Should be Equal As Integers -6 + +Pipe Keyword works correctly with Placeholder + Pipe + ... Sum 1 2 + ... >> Negate $ + ... >> Double $ + ... >> Should be Equal As Integers -6 $ + +Pipe Keyword fails on error + Run Keyword And Expect Error * + ... Pipe + ... Sum 1 2 + ... >> Double + ... >> Should be Equal As Integers 0 + +Pipe Keyword prepends result to arguments by default + Pipe + ... Sum 1 2 + ... >> Subtract 2 + ... >> Should be Equal As Integers 1 + +Pipe Keyword returns value of the last keyword run + ${sum} = Pipe Sum 1 2 >> Double + Should Be Equal As Integers ${sum} 6 \ No newline at end of file diff --git a/tests/02__pipe_strategy_prepend.robot b/tests/02__pipe_strategy_prepend.robot new file mode 100644 index 0000000..c9f24ab --- /dev/null +++ b/tests/02__pipe_strategy_prepend.robot @@ -0,0 +1,13 @@ +*** Settings *** +Library PipeLibrary pipe_strategy=prepend +Resource keywords.resource + +*** Variables *** +${test} abc + +*** Test Cases *** +Pipe Keyword should prepend result to arguments + Pipe + ... Sum 1 2 + ... >> Subtract 2 + ... >> Should be Equal As Integers 1 \ No newline at end of file diff --git a/tests/03__pipe_strategy_append.robot b/tests/03__pipe_strategy_append.robot new file mode 100644 index 0000000..2f44ef3 --- /dev/null +++ b/tests/03__pipe_strategy_append.robot @@ -0,0 +1,10 @@ +*** Settings *** +Library PipeLibrary pipe_strategy=append +Resource keywords.resource + +*** Test Cases *** +Pipe Keyword should append result to arguments + Pipe + ... Sum 1 2 + ... >> Subtract 2 + ... >> Should be Equal As Integers -1 \ No newline at end of file diff --git a/tests/04__custom_placeholder.robot b/tests/04__custom_placeholder.robot new file mode 100644 index 0000000..e5fe399 --- /dev/null +++ b/tests/04__custom_placeholder.robot @@ -0,0 +1,12 @@ +*** Settings *** +Library PipeLibrary placeholder=_ +Resource keywords.resource + +*** Test Cases *** +Pipe Keyword works with custom Placeholder + Pipe + ... Sum 1 2 + ... >> Negate _ + ... >> Double _ + ... >> Should be Equal As Integers -6 _ + diff --git a/tests/05__custom_pipe_operator.robot b/tests/05__custom_pipe_operator.robot new file mode 100644 index 0000000..1fa962c --- /dev/null +++ b/tests/05__custom_pipe_operator.robot @@ -0,0 +1,7 @@ +*** Settings *** +Library PipeLibrary pipe_operator=-> +Resource keywords.resource + +*** Test Cases *** +Pipe Keyword works with custom pipe operator + Pipe Sum 1 2 -> Negate -> Double -> Should be Equal As Integers -6 \ No newline at end of file diff --git a/tests/06__custom.robot b/tests/06__custom.robot new file mode 100644 index 0000000..17be483 --- /dev/null +++ b/tests/06__custom.robot @@ -0,0 +1,12 @@ +*** Settings *** +Library PipeLibrary pipe_strategy=append pipe_operator=-> placeholder=_ +Resource keywords.resource + +*** Test Cases *** +Pipe Keyword works with custom Placeholder and custom pipe operator + Pipe + ... Sum 1 2 + ... -> Double _ + ... -> Subtract 3 + ... -> Should be Equal As Integers -3 _ + diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/keywords.resource b/tests/keywords.resource new file mode 100644 index 0000000..7bd8e65 --- /dev/null +++ b/tests/keywords.resource @@ -0,0 +1,20 @@ +*** Keywords *** +Sum + [Arguments] ${a} ${b} + ${sum} = Evaluate ${a} + ${b} + RETURN ${sum} + +Subtract + [Arguments] ${a} ${b} + ${value} = Evaluate ${a} - ${b} + RETURN ${value} + +Negate + [Arguments] ${num} + ${product} = Evaluate -1 * ${num} + RETURN ${product} + +Double + [Arguments] ${num} + ${double} = Evaluate 2 * ${num} + RETURN ${double} \ No newline at end of file