Browse Source

New command "iban" to generate random IBAN (Intern.Bank account number)

bernhardbuhl 4 years ago
parent
commit
35577b52cf
3 changed files with 19 additions and 0 deletions
  1. 13 0
      baangt/TestSteps/TestStepMaster.py
  2. 1 0
      docs/changelog.rst
  3. 5 0
      docs/simpleExample.rst

+ 13 - 0
baangt/TestSteps/TestStepMaster.py

@@ -132,9 +132,22 @@ class TestStepMaster:
                 value_expected = lValue
                 if value_expected != value_found:
                     raise baangtTestStepException(f"Expected Value: {value_expected}, Value found :{value_found} ")
+            elif lActivity == 'IBAN':
+                # Create Random IBAN. Value1 = Input-Parameter for IBAN-Function. Value2=Fieldname
+                self.__getIBAN(lValue, lValue2)
             else:
                 raise BaseException(f"Unknown command in TestStep {lActivity}")
 
+    def __getIBAN(self, lValue, lValue2):
+        from baangt.base.IBAN import IBAN
+        if not lValue2:
+            logger.critical("IBAN-Method called without destination field name in column 'Value 2'")
+            return
+
+        lIBAN = IBAN()
+        self.testcaseDataDict[lValue2] = lIBAN.getRandomIBAN()
+        pass
+
     @staticmethod
     def _sanitizeXField(inField):
         """

+ 1 - 0
docs/changelog.rst

@@ -8,6 +8,7 @@ Summary:
 
 New features
 ++++++++++++
+* SimpleFormat: New short command ``iban`` will create a random IBAN. Powered by Schwifty library.
 
 Changes
 +++++++

+ 5 - 0
docs/simpleExample.rst

@@ -223,6 +223,11 @@ More details on Activities
 
    * - pause
      - Will pause for the number of secons in ``value``. Valid numbers are float, e.g. 2, 0.2, 0.1, 25
+   * - iban
+     - Will create a random IBAN account number. ``value 2`` is the destination field of the test case structure. If you
+       don't provide a field name (not necessarily one that exists in the input file. Can be any field name!) nothing will
+       happen. If you provide input parameters in column ``value`` (``SWIFT`` and/or ``COUNTRY``) the IBAN will be created for that bank-code
+       and/or country.
    * - address_create
      - provide an easy and easily extendable way to generate address data for a test case
        The following fields variable are stored in testcaseDataDict: