Browse Source

start-dialog - select testcase-args

refactor
Ulrich 1 year ago
parent
commit
030ac13261
  1. 2
      model/testcase.py
  2. 32
      test/test_10job.py
  3. 20
      tools/filecsv_fcts.py
  4. 29
      tools/job_tool.py

2
model/testcase.py

@ -121,6 +121,7 @@ class Testcase(model.entity.Entity):
# r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") # r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001")
config = self.getConfig(job, P.KEY_TESTCASE, name, tools.config_tool.get_plain_filename(job, name)) config = self.getConfig(job, P.KEY_TESTCASE, name, tools.config_tool.get_plain_filename(job, name))
self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES)
"""
for k in LIST_SUBTABLES.keys(): for k in LIST_SUBTABLES.keys():
if not hasattr(self, k): if not hasattr(self, k):
continue continue
@ -137,6 +138,7 @@ class Testcase(model.entity.Entity):
for l in config[name]["_"+k]: for l in config[name]["_"+k]:
values[config[name]["_" + k][l]] = "" values[config[name]["_" + k][l]] = ""
setattr(self, k, values) setattr(self, k, values)
"""
return self return self
def xxread_entity(self, job, name): def xxread_entity(self, job, name):

32
test/test_10job.py

@ -2,15 +2,10 @@ import unittest
import os import os
import inspect import inspect
import shutil import shutil
print("start import 1")
#import model.entity #import model.entity
print("start import 2")
#import model.environment #import model.environment
print("start import 3")
#import model.application #import model.application
print("start import 4")
#import model.component #import model.component
print("start import 5")
import model.testcase import model.testcase
import model.testsuite import model.testsuite
import model.factory import model.factory
@ -28,9 +23,9 @@ HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_00init", TEST_FUNCTIONS = ["test_00init",
"test_11selectApplication", "test_12selectComponent", "test_13selectEnvironment", "test_11selectApplication", "test_12selectComponent", "test_13selectEnvironment",
"test_16selectTestcase", "test_14selectVariant", "test_16selectTestcase",
"test_30startActJob"] "test_30startActJob"]
TEST_FUNCTIONS = ["test_16selectTestcase"] TEST_FUNCTIONS = ["test_14selectVariant"]
PROGRAM_NAME = "clean_workspace" PROGRAM_NAME = "clean_workspace"
@ -110,6 +105,29 @@ class MyTestCase(unittest.TestCase):
self.assertIsInstance(res, list) self.assertIsInstance(res, list)
print(str(res)) print(str(res))
def test_14selectVariant(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
# simple job instantiate - without parameter and only simple messaging
job = basic.program.Job(PROGRAM_NAME)
args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich',
'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer',
'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0002'}
res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res))
self.assertEqual(len(res), 1)
self.assertEqual("defaultVariant", res[0])
args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich',
'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer',
'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0001'}
res = tools.job_tool.select_variant(job, "", "Testfall", args)
print(str(res))
self.assertEqual(len(res), 2)
self.assertEqual("xml-rest", res[0])
def test_14selectTestplan(self): def test_14selectTestplan(self):
global mymsg global mymsg
actfunction = str(inspect.currentframe().f_code.co_name) actfunction = str(inspect.currentframe().f_code.co_name)

20
tools/filecsv_fcts.py

@ -53,15 +53,16 @@ class FileFcts(tools.file_abstract.FileFcts):
:param status: :param status:
:return: :return:
""" """
verify = False
try: try:
print("isBlock "+field + " , " + block + " , " + status) if verify: print("isBlock "+field + " , " + block + " , " + status)
blockPur = tools.data_tool.getPurKeyword(block) blockPur = tools.data_tool.getPurKeyword(block)
a = field.split(":") a = field.split(":")
keyPur = tools.data_tool.getPurKeyword(a[0]) keyPur = tools.data_tool.getPurKeyword(a[0])
statusPur = tools.data_tool.getPurKeyword(status) statusPur = tools.data_tool.getPurKeyword(status)
if statusPur+"s-" in keyPur: if statusPur+"s-" in keyPur:
keyPur = keyPur[keyPur.find("-")+1:] keyPur = keyPur[keyPur.find("-")+1:]
print("isBlock "+a[0] + "=" + keyPur +" , " + blockPur + " , " + status) if verify: print("isBlock "+a[0] + "=" + keyPur +" , " + blockPur + " , " + status)
if (keyPur+"s" in D.LIST_SUBTABLES or keyPur in D.LIST_SUBTABLES) \ if (keyPur+"s" in D.LIST_SUBTABLES or keyPur in D.LIST_SUBTABLES) \
and block == D.CSV_BLOCK_SUBTABLES: and block == D.CSV_BLOCK_SUBTABLES:
return True return True
@ -386,21 +387,28 @@ def setSubTable(job, subtable, key, val):
# descriptiom => attribute of actual subtable # descriptiom => attribute of actual subtable
key = key.lower() key = key.lower()
subkey = "" subkey = ""
newSubtable = False
print("setSubtable "+key+", "+str(val)) print("setSubtable "+key+", "+str(val))
if "actTable" in subtable and subtable["actTable"]+"-" in key: if "actTable" in subtable and subtable["actTable"]+"-" in key:
subkey = key[key.find("-")+1:] subkey = key[key.find("-")+1:]
if subkey == "" and key not in subtable: if subkey == "" and key not in subtable:
newSubtable = True
subtable[key] = {} subtable[key] = {}
subtable["actTable"] = key subtable["actTable"] = key
actTable = subtable["actTable"] actTable = subtable["actTable"]
purKey = tools.data_tool.getPurKeyword(key)
print("setSubtable "+key+" =? "+actTable+ " + "+ purKey +" , "+str(val))
actKeys = list(subtable[actTable].keys())
for i in range(1, len(val)): for i in range(1, len(val)):
if val[i] not in subtable[key]: if newSubtable and val[i] not in subtable[key]:
if val[i] == "": if val[i] == "":
break break
subtable[key][val[i]] = {} subtable[actTable][val[i]] = {}
subtable[key][val[i]]["name"] = val[i] subtable[actTable][val[i]]["name"] = val[i]
else: else:
subtable[key][val[i]][key] = val[i] if i >= len(actKeys):
break
subtable[actTable][actKeys[i]][purKey] = val[i]
return subtable return subtable
def setTableAttribute(job, tableAttr, key, val): def setTableAttribute(job, tableAttr, key, val):

29
tools/job_tool.py

@ -264,26 +264,35 @@ def select_variant(job, programDef, gran, args):
read the testobjects of the granularity,project and select one of them with the time read the testobjects of the granularity,project and select one of them with the time
:return: :return:
""" """
outVariants = []
print("select spec "+gran) print("select spec "+gran)
if gran == J.GRAN_TP.lower(): if gran == J.GRAN_TP.lower():
setParameterArgs(job, args, [B.PAR_PROJ])
print("select tp spec " + gran) print("select tp spec " + gran)
return [""] return [""]
elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]: elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]:
setParameterArgs(job, args, [B.PAR_PROJ])
print("select ts spec " + gran) print("select ts spec " + gran)
out = model.testsuite.select_testsuite(job, args[B.PAR_PROJ], args[B.PAR_TESTSUITE]) out = model.testsuite.select_testsuite(job, args[B.PAR_PROJ], args[B.PAR_TESTSUITE])
if "variant" not in out: if "variant" not in out:
return [""] return [""]
return list(out["variant"].keys()) return list(out["variant"].keys())
elif gran in [B.PAR_TESTCASE, J.GRAN_TC]: elif gran in [B.PAR_TESTCASE, J.GRAN_TC]:
setParameterArgs(job, args, [B.PAR_PROJ])
print("select tc spec " + gran + " " + str(args)) print("select tc spec " + gran + " " + str(args))
out = model.factory.getTestcase(job, args[B.PAR_PROJ]).read_entity(job, args[B.PAR_TESTCASE]) testcase = model.factory.getTestcase(job, args[B.PAR_PROJ]).read_entity(job, args[B.PAR_TESTCASE])
print(str(out)) print(str(testcase))
if "variant" not in out: #if "variant" not in testcase:
return [""] # return [""]
return list(out["variant"].keys()) if hasattr(testcase, B.SUBJECT_VARIANTS):
outVariants = list(getattr(testcase, B.SUBJECT_VARIANTS).keys())
#return list(testcase[B.SUBJECT_VARIANTS].keys())
else: else:
raise Exception("for gran "+gran+" variant can not be selected") raise Exception("for gran "+gran+" variant can not be selected")
if len(outVariants) == 0:
outVariants.append("defaultVariant")
print("select no spec "+gran) print("select no spec "+gran)
return outVariants
def select_testplan(job, programDef, args): def select_testplan(job, programDef, args):
outList = [] outList = []
@ -299,3 +308,13 @@ def select_testcase(job, programDef, args):
# outList = model.testcase.select_testcases(job, [args[B.PAR_PROJ]], [args[B.PAR_APP]]) # outList = model.testcase.select_testcases(job, [args[B.PAR_PROJ]], [args[B.PAR_APP]])
outList = model.factory.getTestcase(job, args[B.PAR_PROJ]).get_unique_names(job, project=args[B.PAR_PROJ], application=args[B.PAR_APP]) outList = model.factory.getTestcase(job, args[B.PAR_PROJ]).get_unique_names(job, project=args[B.PAR_PROJ], application=args[B.PAR_APP])
return outList return outList
def setParameterArgs(job, args, parameter):
if not hasattr(job, "par"):
job.setParameter({})
# setattr(job, "par", object)
for p in parameter:
if hasattr(job.par, p):
continue
if p in args:
setattr(job.par, p, args[p])
Loading…
Cancel
Save