|
|
@ -1,3 +1,12 @@ |
|
|
|
#!/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 |
|
|
@ -8,13 +17,14 @@ import test.testtools |
|
|
|
import utils.path_const as P |
|
|
|
import basic.constants as B |
|
|
|
|
|
|
|
TEST_FUNCTIONS = ["test_getConfig", "test_mergeAttributes"] |
|
|
|
VERIFY = False |
|
|
|
TEST_FUNCTIONS = ["test_01getConfig", "test_02mergeAttributes", "test_03getAttributes"] |
|
|
|
#TEST_FUNCTIONS = ["test_03getAttributes"] |
|
|
|
verbose = False |
|
|
|
|
|
|
|
class MyTestCase(unittest.TestCase): |
|
|
|
mymsg = "--------------------------------------------------------------" |
|
|
|
|
|
|
|
def test_getConfig(self): |
|
|
|
def test_01getConfig(self): |
|
|
|
global mymsg |
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
cnttest = 0 |
|
|
@ -39,12 +49,12 @@ class MyTestCase(unittest.TestCase): |
|
|
|
r = utils.config_tool.getConfigPath(P.KEY_COMP, "testcrm") |
|
|
|
self.assertIn(os.path.join(job.conf.getPath(P.ATTR_PATH_COMPONENTS), "testcrm", "CONFIG"), r) |
|
|
|
r = utils.config_tool.getConfig(P.KEY_TOOL, "path") |
|
|
|
if VERIFY: print("pattern " + r["pattern"]["log"]) |
|
|
|
if VERIFY: print("pattern " + r["pattern"]["precond"]) |
|
|
|
if verbose: print("pattern " + r["pattern"]["log"]) |
|
|
|
if verbose: print("pattern " + r["pattern"]["precond"]) |
|
|
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|
|
|
|
|
|
|
|
|
|
|
def test_mergeAttributes(self): |
|
|
|
def test_02mergeAttributes(self): |
|
|
|
global mymsg |
|
|
|
actfunction = str(inspect.currentframe().f_code.co_name) |
|
|
|
cnttest = 0 |
|
|
@ -65,20 +75,26 @@ class MyTestCase(unittest.TestCase): |
|
|
|
componentName = "testprddb" |
|
|
|
confs = utils.config_tool.getConfig("comp", componentName) |
|
|
|
conns = utils.conn_tool.getConnections(componentName) |
|
|
|
self.assertNotIn(B.ATTR_DB_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) |
|
|
|
self.assertNotIn(B.ATTR_ARTS_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) |
|
|
|
confs["conf"] = utils.config_tool.mergeConn(job.m, confs["conf"], conns[0]) |
|
|
|
self.assertIn(B.ATTR_DB_TYPE, confs["conf"][B.SUBJECT_ARTS][B.TOPIC_NODE_DB]) |
|
|
|
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_getAttributes(self): |
|
|
|
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("testprddb") |
|
|
|
path = "db.product" |
|
|
|
attrList = utils.config_tool.getAttributeList(comp, path, job) |
|
|
|
self.assertIn(B.ATTR_ARTS_PATH, attrList) |
|
|
|
self.assertIn(B.ATTR_ARTS_RESET, attrList) |
|
|
|
cnttest += 2 # new attribute |
|
|
|
MyTestCase.mymsg += "\n----- "+actfunction+" : "+str(cnttest) |
|
|
|
|
|
|
|
|
|
|
@ -87,5 +103,5 @@ class MyTestCase(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
VERIFY = True |
|
|
|
verbose = True |
|
|
|
unittest.main() |
|
|
|