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)
x.m.setMsg("# Components initialized with these relevant components " + str(comps))
for c in comps:
comp = cm.getComponents(c)
comp = cm.getComponent(c)
print(str(comp))
comp.check_Instance()
x.m.merge(comp.m)
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.program
import inspect
import utils.db_abstract
import basic.toolHandling
import components.component
import basic.componentHandling
class Testexecuter():
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())
if "log" in self.conf["artifact"]:
self.m.logInfo("log rotate in "+ self.name)
if "flaskdb" in self.conf["artifact"]:
self.m.logInfo("delete flaskdb-content "+ self.name)
if "db" in self.conf["artifact"]:
self.m.logInfo("delete content "+ self.name)
dbi = basic.toolHandling.getDbTool(self)
dbi.deleteTables()
if "lob" in self.conf["artifact"]:
self.m.logInfo("lob is deleted with flaskdb "+ self.name)
if "file" in self.conf["artifact"]:
@ -84,9 +88,13 @@ class Testexecuter():
job = basic.program.Job.getInstance()
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())
if "testdata" in self.conf:
if self.conf["testdata"] == "flaskdb":
self.m.logInfo("insert flaskdb-content " + self.name)
plainname = basic.componentHandling.getPlainCompname(self.name)
if plainname in testdata:
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.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()
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())
if "flaskdb" in self.conf["artifact"]:
self.m.logInfo("select flaskdb-content "+ self.name)
if "db" in self.conf["artifact"]:
self.m.logInfo("select db-content "+ self.name)
dbi = basic.toolHandling.getDbTool(self)
dbi.selectTables()
if "lob" in self.conf["artifact"]:
self.m.logInfo("check lob if is deleted with flaskdb "+ self.name)
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 yaml # pip install pyyaml
import basic.program as program
import utils.tdata_tool
from basic.componentHandling import ComponentManager
import basic.message as message
# 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.
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.
if __name__ == '__main__':
x = program.Job("check_environment")
print(PROGRAM_NAME)
x = program.Job(PROGRAM_NAME)
#m = message.Message(3)
#m.closeMessage()
x.startJob()
x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung")
x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf)))
cm = ComponentManager()
if x.m.isRc("fatal"):
x.stopJob()
exit(x.m.rc * (-1) + 3)
start(x)
x.stopJob()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

Loading…
Cancel
Save