Browse Source

job exercises

master
Ulrich Carmesin 3 years ago
parent
commit
ac4397d99e
  1. 3
      check_environment.py
  2. 26
      components/testexec.py
  3. 24
      init_testcase.py

3
check_environment.py

@ -25,7 +25,8 @@ if __name__ == '__main__':
comps = cm.getComponents(PROGRAM_NAME) comps = cm.getComponents(PROGRAM_NAME)
x.m.setMsg("# Components initialized with these relevant components " + str(comps)) x.m.setMsg("# Components initialized with these relevant components " + str(comps))
for c in comps: for c in comps:
comp = cm.getComponents(c) comp = cm.getComponent(c)
print(str(comp))
comp.check_Instance() comp.check_Instance()
x.m.merge(comp.m) x.m.merge(comp.m)
comp.confs["function"][PROGRAM_NAME] = comp.m.topmessage comp.confs["function"][PROGRAM_NAME] = comp.m.topmessage

26
components/testexec.py

@ -31,8 +31,10 @@ from datetime import datetime
import basic.message import basic.message
import basic.program import basic.program
import inspect import inspect
import utils.db_abstract
import basic.toolHandling
import components.component import components.component
import basic.componentHandling
class Testexecuter(): class Testexecuter():
def prepare_system(self, granularity): def prepare_system(self, granularity):
@ -64,8 +66,10 @@ class Testexecuter():
+ datetime.now().strftime("%Y%m%d_%H%M%S")+" for " + str(self.name).upper()) + datetime.now().strftime("%Y%m%d_%H%M%S")+" for " + str(self.name).upper())
if "log" in self.conf["artifact"]: if "log" in self.conf["artifact"]:
self.m.logInfo("log rotate in "+ self.name) self.m.logInfo("log rotate in "+ self.name)
if "flaskdb" in self.conf["artifact"]: if "db" in self.conf["artifact"]:
self.m.logInfo("delete flaskdb-content "+ self.name) self.m.logInfo("delete content "+ self.name)
dbi = basic.toolHandling.getDbTool(self)
dbi.deleteTables()
if "lob" in self.conf["artifact"]: if "lob" in self.conf["artifact"]:
self.m.logInfo("lob is deleted with flaskdb "+ self.name) self.m.logInfo("lob is deleted with flaskdb "+ self.name)
if "file" in self.conf["artifact"]: if "file" in self.conf["artifact"]:
@ -84,9 +88,13 @@ class Testexecuter():
job = basic.program.Job.getInstance() job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name) verify = -1+job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
if "testdata" in self.conf: plainname = basic.componentHandling.getPlainCompname(self.name)
if self.conf["testdata"] == "flaskdb": if plainname in testdata:
self.m.logInfo("insert flaskdb-content " + self.name) print("plainname in testdata "+plainname)
if "db" in self.conf["artifact"]:
self.m.logInfo("delete content "+ self.name)
dbi = basic.toolHandling.getDbTool(self)
dbi.insertTables(testdata)
self.m.setMsg("data loaded for " + self.name + " is OK") self.m.setMsg("data loaded for " + self.name + " is OK")
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() finished at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() finished at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
@ -99,8 +107,10 @@ class Testexecuter():
job = basic.program.Job.getInstance() job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name) verify = -1+job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper()) self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
if "flaskdb" in self.conf["artifact"]: if "db" in self.conf["artifact"]:
self.m.logInfo("select flaskdb-content "+ self.name) self.m.logInfo("select db-content "+ self.name)
dbi = basic.toolHandling.getDbTool(self)
dbi.selectTables()
if "lob" in self.conf["artifact"]: if "lob" in self.conf["artifact"]:
self.m.logInfo("check lob if is deleted with flaskdb "+ self.name) self.m.logInfo("check lob if is deleted with flaskdb "+ self.name)
self.m.setMsg("readInstance for " + self.name + " is OK") self.m.setMsg("readInstance for " + self.name + " is OK")

24
init_testcase.py

@ -3,26 +3,46 @@ import sys#
# import jsonpickle # pip install jsonpickle # import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml import yaml # pip install pyyaml
import basic.program as program import basic.program as program
import utils.tdata_tool
from basic.componentHandling import ComponentManager from basic.componentHandling import ComponentManager
import basic.message as message import basic.message as message
# Press Umschalt+F10 to execute it or replace it with your code. # Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
PROGRAM_NAME = "init_testcase"
def start(x):
cm = ComponentManager()
print("cm "+str(cm))
cm.initComponents()
comps = cm.getComponents(PROGRAM_NAME)
x.m.setMsg("# Components initialized with these relevant components " + str(comps))
testdata = utils.tdata_tool.getTestdata()
for c in comps:
comp = cm.getComponent(c)
comp.m.logInfo("------- "+comp.name+" ----------------------------------------")
comp.reset_TData("testcase")
comp.load_TData("testcase", testdata)
comp.read_TData("testcase")
comp.m.logInfo("------- "+comp.name+" ----------------------------------------")
x.m.merge(comp.m)
print(str(comp))
comp.conf["function"][PROGRAM_NAME] = comp.m.topmessage
# Press the green button in the gutter to run the script. # Press the green button in the gutter to run the script.
if __name__ == '__main__': if __name__ == '__main__':
x = program.Job("check_environment") print(PROGRAM_NAME)
x = program.Job(PROGRAM_NAME)
#m = message.Message(3) #m = message.Message(3)
#m.closeMessage() #m.closeMessage()
x.startJob() x.startJob()
x.m.logInfo("hier eine LogInfo") x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung") x.m.logDebug("hier eine DbugMeldung")
x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf))) x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf)))
cm = ComponentManager()
if x.m.isRc("fatal"): if x.m.isRc("fatal"):
x.stopJob() x.stopJob()
exit(x.m.rc * (-1) + 3) exit(x.m.rc * (-1) + 3)
start(x)
x.stopJob() x.stopJob()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ # See PyCharm help at https://www.jetbrains.com/help/pycharm/

Loading…
Cancel
Save