Skip to content

Commit

Permalink
feat/add map param function and poeditor module (#263)
Browse files Browse the repository at this point in the history
* Add CONF and POE replacements logic

* Complete the set of map_param replacements

* Add unit tests and documentation about the available replacements

* Improve documentation layout

* Improve documentation layout

* Improve documentation layout

* Linting comments

* Linting comments

* Improve documentation layout

* Remove unintended file

* Add .vscode folder to .gitignore

* Reduce complexity score of map_param function and fix copyright claims
  • Loading branch information
pabloge committed Feb 3, 2022
1 parent 2c08028 commit 80563ab
Show file tree
Hide file tree
Showing 12 changed files with 1,231 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -6,6 +6,9 @@
target
.pydevproject

# VSCode IDE
.vscode

# Packages
*.egg
*.egg-info
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -7,6 +7,7 @@ v2.2.2
*Release date: In development*

- Add missing param in download_videos method to fix error downloading videos from a remote server
- Add map_param function to dataset module
- New param [RANDOM_PHONE_NUMBER] in *replace_param* method to generate random phone number

v2.2.1
Expand Down
48 changes: 48 additions & 0 deletions docs/bdd_integration.rst
Expand Up @@ -144,6 +144,54 @@ When this happens, steps of the affected scenarios for that precondition are not
first step defined in those scenarios will be automatically failed because of that precondition exception,
in order to properly fail the execution and show the stats.

Behave variables transformation
-------------------------------

Toolium provides a set of functions that allow the transformation of specific string tags into different values.
These are the main ones, along with the list of tags they support and their associated replacement logic (click on the
functions or check the :ref:`dataset <dataset>` module for more implementation details):

`replace_param <https://toolium.readthedocs.io/en/latest/toolium.utils.html#toolium.utils.dataset.replace_param>`_:

* :code:`[STRING_WITH_LENGTH_XX]`: Generates a fixed length string
* :code:`[INTEGER_WITH_LENGTH_XX]`: Generates a fixed length integer
* :code:`[STRING_ARRAY_WITH_LENGTH_XX]`: Generates a fixed length array of strings
* :code:`[INTEGER_ARRAY_WITH_LENGTH_XX]`: Generates a fixed length array of integers
* :code:`[JSON_WITH_LENGTH_XX]`: Generates a fixed length JSON
* :code:`[MISSING_PARAM]`: Generates a None object
* :code:`[NULL]`: Generates a None object
* :code:`[TRUE]`: Generates a boolean True
* :code:`[FALSE]`: Generates a boolean False
* :code:`[EMPTY]`: Generates an empty string
* :code:`[B]`: Generates a blank space
* :code:`[RANDOM]`: Generates a random value
* :code:`[RANDOM_PHONE_NUMBER]`: Generates a random phone number following the pattern +34654XXXXXX
* :code:`[TIMESTAMP]`: Generates a timestamp from the current time
* :code:`[DATETIME]`: Generates a datetime from the current time
* :code:`[NOW]`: Similar to DATETIME without milliseconds; the format depends on the language
* :code:`[NOW + 2 DAYS]`: Similar to NOW but two days later
* :code:`[NOW - 1 MINUTES]`: Similar to NOW but one minute earlier
* :code:`[TODAY]`: Similar to NOW without time; the format depends on the language
* :code:`[TODAY + 2 DAYS]`: Similar to NOW, but two days later
* :code:`[STR:xxxx]`: Cast xxxx to a string
* :code:`[INT:xxxx]`: Cast xxxx to an int
* :code:`[FLOAT:xxxx]`: Cast xxxx to a float
* :code:`[LIST:xxxx]`: Cast xxxx to a list
* :code:`[DICT:xxxx]`: Cast xxxx to a dict
* :code:`[UPPER:xxxx]`: Converts xxxx to upper case
* :code:`[LOWER:xxxx]`: Converts xxxx to lower case

`map_param <https://toolium.readthedocs.io/en/latest/toolium.utils.html#toolium.utils.dataset.map_param>`_:

* :code:`[CONF:xxxx]`: Value from the config dict in context.project_config for the key xxxx
* :code:`[LANG:xxxx]`: String from the texts dict in context.language_dict for the key xxxx, using the language specified in context.language
* :code:`[POE:xxxx]`: Definition(s) from the POEditor terms list in context.poeditor_terms for the term xxxx (see :ref:`poeditor <poeditor>` module for details)
* :code:`[TOOLIUM:xxxx]`: Value from the toolium config in context.toolium_config for the key xxxx
* :code:`[CONTEXT:xxxx]`: Value from the context storage dict for the key xxxx, or value of the context attribute xxxx, if the former does not exist
* :code:`[ENV:xxxx]`: Value of the OS environment variable xxxx
* :code:`[FILE:xxxx]`: String with the content of the file in the path xxxx
* :code:`[BASE64:xxxx]`: String with the base64 representation of the file content in the path xxxx


Lettuce
~~~~~~~
Expand Down
20 changes: 20 additions & 0 deletions docs/toolium.rst
Expand Up @@ -72,6 +72,26 @@ jira
:undoc-members:
:show-inheritance:

.. _pytest_fixtures:

pytest_fixtures
---------------

.. automodule:: toolium.pytest_fixtures
:members:
:undoc-members:
:show-inheritance:

.. _selenoid:

selenoid
--------

.. automodule:: toolium.selenoid
:members:
:undoc-members:
:show-inheritance:

.. _test_cases:

test_cases
Expand Down
46 changes: 45 additions & 1 deletion docs/toolium.utils.rst
@@ -1,7 +1,29 @@
.. _utils:

utils
=====

.. _utils:
.. _dataset:

dataset
-------

.. automodule:: toolium.utils.dataset
:members:
:undoc-members:
:show-inheritance:

.. _download_files:

download_files
--------------

.. automodule:: toolium.utils.download_files
:members:
:undoc-members:
:show-inheritance:

.. _driver_utils:

driver_utils
------------
Expand All @@ -11,10 +33,32 @@ driver_utils
:undoc-members:
:show-inheritance:

.. _driver_wait_utils:

driver_wait_utils
-----------------

.. automodule:: toolium.utils.driver_utils
:members:
:undoc-members:
:show-inheritance:

.. _path_utils:

path_utils
----------

.. automodule:: toolium.utils.path_utils
:members:
:undoc-members:
:show-inheritance:

.. _poeditor:

poeditor
--------

.. automodule:: toolium.utils.poeditor
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions toolium/test/resources/document.txt
@@ -0,0 +1 @@
Document used to verify functionalities in MSS
7 changes: 7 additions & 0 deletions toolium/test/resources/toolium.cfg
@@ -0,0 +1,7 @@
[Driver]
# Valid driver types: firefox, chrome, iexplore, edge, safari, opera, phantomjs, ios, android
type: firefox

[TestExecution]
environment: QA
language: EN

0 comments on commit 80563ab

Please sign in to comment.