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.
 
 
 

137 lines
6.0 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# https://ucarmesin.de/index.php/it/testautomatisierung-fuer-daten-test/225-konfiguration-der-testanwendung
# ---------------------------------------------------------------------------------------------------------
import sys
import basic.constants as B
import unittest
import os
import inspect
import tools.config_tool
import tools.conn_tool
import test.constants as T
import test.testtools
import tools.path_const as P
import basic.constants as B
TEST_FUNCTIONS = ["test_01getConfigPath", "test_02mergeAttributes", "test_03getAttributes",
"test_20getPlainName"]
TEST_FUNCTIONS = ["test_01getConfigPath"]
verbose = False
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_01getConfigPath(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
x = B.SUBJECT_APPS
r = tools.config_tool.select_config_path(job, P.KEY_BASIC, x)
self.assertIn(os.path.join(T.COMP_PATH, P.VAL_CONFIG, B.SUBJECT_APPS), r)
cnttest += 1
x = "path"
r = tools.config_tool.select_config_path(job, P.KEY_TOOL, x)
self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], P.VAL_CONFIG), r)
cnttest += 1
x = "conn"
r = tools.config_tool.select_config_path(job, P.KEY_TOOL, x)
self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV]), r)
cnttest += 1
self.assertRaises(Exception, tools.config_tool.select_config_path, (job, P.KEY_COMP, "TestX2"))
# self.assertEqual(r, None)
cnttest += 1
r = tools.config_tool.select_config_path(job, P.KEY_COMP, "testcrm")
self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], "testcrm", "CONFIG"), r)
cnttest += 1
r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001")
self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTCASES, "TC0001", "test"), r)
cnttest += 1
r = tools.config_tool.select_config_path(job, P.KEY_TESTSUITE, "TST001")
self.assertIn(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], "TESTPROJ", B.SUBJECT_TESTSUITES, "TST001", "test"), r)
r = tools.config_tool.getConfig(job, P.KEY_TOOL, "path")
if verbose: print("pattern " + r["pattern"]["log"])
if verbose: print("pattern " + r["pattern"]["precond"])
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_02mergeAttributes(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
componentName = "testcm"
confs = tools.config_tool.getConfig(job, "comp", componentName)
conns = tools.conn_tool.getConnections(job, componentName)
self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_CNT], 1)
self.assertEqual(conns[0][B.SUBJECT_INST][B.ATTR_INST_CNT], 2)
self.assertNotIn(B.ATTR_INST_SGL, conns[0][B.SUBJECT_INST])
confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0])
self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_CNT], 2)
cnttest += 1 # it overwrites
self.assertEqual(confs["conf"][B.SUBJECT_INST][B.ATTR_INST_SGL], "n")
cnttest += 1 # it keep
componentName = "testprddb"
confs = tools.config_tool.getConfig(job, "comp", componentName)
conns = tools.conn_tool.getConnections(job, componentName)
self.assertNotIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB])
confs["conf"] = tools.config_tool.mergeConn(job.m, confs["conf"], conns[0])
self.assertIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB])
cnttest += 1 # new attribute
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_03getAttributes(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
comp = test.testtools.getComp(job, "testprddb")
path = "db.product"
attrList = tools.config_tool.getAttributeList(comp, path, job)
self.assertIn(B.ATTR_ARTS_PATH, attrList)
self.assertIn(B.ATTR_ARTS_RESET, attrList)
cnttest += 2 # new attribute
comp = test.testtools.getComp(job, "testrest")
path = "file.xmlrest"
attrList = tools.config_tool.getAttributeList(comp, path, job)
#print(str(comp.conf["conn"]))
#print(str(comp.conf[B.SUBJECT_ARTS]))
#print(str(attrList))
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest)
def test_20getPlainName(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
for ext in tools.config_tool.CONFIG_FORMAT:
plain = tools.config_tool.get_plain_filename(job, "testfall." + ext)
self.assertEqual(plain, "testfall")
for ext in tools.config_tool.CONFIG_FORMAT:
plain = tools.config_tool.get_plain_filename(job, os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM],
P.ATTR_PATH_TDATA, "testfall." + ext))
self.assertEqual(plain, "testfall")
def test_zzz(self):
print(MyTestCase.mymsg)
if __name__ == '__main__':
verbose = True
unittest.main()