Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.7 KiB

2 years ago
#!/usr/bin/python
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# https://ucarmesin.de/index.php/it/testautomatisierung-fuer-daten-test/232-testfallgenerierung
# ---------------------------------------------------------------------------------------------------------
import re
import utils.config_tool
import utils.path_const as P
import basic.constants as B
import basic.program
import utils.gen_const as G
import random
import basic.catalog
VAL_CLASSES: {
"xvarnum": {
G.CLS_MISFORMAT: "str",
G.CLS_NONE: None,
G.CLS_EMPTY: 0,
G.CLS_LESS: True,
G.CLS_GREATER: True,
G.ATTR_MIN_COUNT: 5
},
"xvarnum": {
G.CLS_MISFORMAT: "str,feb",
G.CLS_NONE: None,
G.CLS_EMPTY: 0,
G.CLS_LESS: True,
G.CLS_GREATER: True,
G.ATTR_MIN_COUNT: 6
},
"xvarstr": {
G.CLS_MISFORMAT: "num,sym,koeln",
G.CLS_NONE: None,
G.CLS_EMPTY: 0,
G.CLS_LESS: False,
G.CLS_GREATER: False,
G.ATTR_MIN_COUNT: 7
}
}
def getCntElement(values, job):
if G.VAL_SECTOR in values:
return 2
elif G.VAL_DELIMITER in values:
a = values.split(G.VAL_DELIMITER)
return len(a)
elif G.VAL_CATALOG + ":" in values:
a = [0, 1, 2, 3, 4]
return len(a)
return 1
def getValueList(values, count, job):
out = []
for i in range(0, count):
out.append(values[i % len(values)])
print(str(out))
return out
def getMinCount(formula, values, job):
"""
:param formula:
:param values: definition of value-list
:param job:
:return: count of necessary values
"""
if G.KEY_RANDOM in formula:
return 1
elif formula[0:1] == G.KEY_PREFIX_X:
elems = getCntElement(values, job)
factor = 1
if VAL_CLASSES[formula][G.CLS_LESS]:
factor = factor * 2
if VAL_CLASSES[formula][G.CLS_GREATER]:
factor = factor * 2
return VAL_CLASSES[formula][G.ATTR_MIN_COUNT] + factor * (elems - 1)
elif formula == G.KEY_LIST:
return getCntElement(values, job)
return 1
def getElemList(formula, values, count, job):
"""
:param formula:
:param values:
:param count:
:param job:
:return:
"""
out = []
verbose = False
if verbose: print(values+" , "+str(count))
sector_regex = r"(.*)" + re.escape(G.VAL_SECTOR)+ r"(.*)"
delim_regex = r"(.*)" + re.escape(G.VAL_DELIMITER)+ r"(.*)"
catalog_regex = re.escape(G.VAL_CATALOG)+ r":(.*)"
if re.match(sector_regex, values):
if verbose: print("match 1")
temp = []
res = re.search(sector_regex, values)
start = res.group(1)
target = res.group(2)
if start.isdecimal() and target.isdecimal():
for i in range(int(start), int(target)):
temp.append(str(i))
if target not in temp:
temp.append(target)
if verbose: print(str(start)+" - "+str(target)+" : "+str(temp))
elif re.match(delim_regex, values):
if verbose: print("match 2")
temp = values.split(G.VAL_DELIMITER)
for i in range(0, len(temp)): temp[i] = temp[i].strip()
if verbose: print(str(temp))
elif re.match(catalog_regex, values):
res = re.search(catalog_regex, values)
domain = res.group(1)
catalog = basic.catalog.Catalog.getInstance()
temp = catalog.getKeys(domain, job)
if not isinstance(temp, list):
temp = []
while len(temp) > 0 and len(out) < count:
out += temp
return out[0:count]