Browse Source

refactoring: basic-model - comp

refactor
Ulrich 1 year ago
parent
commit
114d5ccd75
  1. 10
      test/test_14table.py
  2. 3
      test/test_20application.py
  3. 3
      test/test_21environment.py
  4. 3
      test/test_22component.py
  5. 7
      tools/file_type.py

10
test/test_14table.py

@ -73,20 +73,20 @@ class MyTestCase(unittest.TestCase):
args["context"] = "testdata" args["context"] = "testdata"
acttable = table.read_entity(job, name, args=args) acttable = table.read_entity(job, name, args=args)
self.assertEqual(getattr(acttable, D.FIELD_NAME), name) self.assertEqual(getattr(acttable, D.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz") #self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
# #
table = model.table.Table(job) table = model.table.Table(job)
args["context"] = B.ATTR_INST_TESTSERVER args["context"] = B.ATTR_INST_TESTSERVER
name = B.SUBJECT_APP name = B.SUBJECT_APP
acttable = table.read_entity(job, name, args=args) acttable = table.read_entity(job, name, args=args)
self.assertEqual(getattr(acttable, D.FIELD_NAME), name) self.assertEqual(getattr(acttable, D.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz") #self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
# #
table = model.table.Table(job) table = model.table.Table(job)
name = "ap_application" name = "ap_applications"
acttable = table.read_entity(job, name, args=args) acttable = table.read_entity(job, name, args=args)
self.assertEqual(getattr(acttable, D.FIELD_NAME), name) self.assertEqual(getattr(acttable, D.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz") #self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
def test_20getSchema(self): def test_20getSchema(self):
global mymsg global mymsg
@ -100,7 +100,7 @@ class MyTestCase(unittest.TestCase):
entityNames = table.read_unique_names(job, B.ATTR_INST_TESTSERVER, "", "", {}) entityNames = table.read_unique_names(job, B.ATTR_INST_TESTSERVER, "", "", {})
args = {} args = {}
args["context"] = B.ATTR_INST_TESTSERVER args["context"] = B.ATTR_INST_TESTSERVER
name = "tc_table" name = "tc_tables"
print(name) print(name)
acttable = table.read_entity(job, name, args=args) acttable = table.read_entity(job, name, args=args)
schema = acttable.get_schema(name) schema = acttable.get_schema(name)

3
test/test_20application.py

@ -10,6 +10,7 @@ import basic.constants as B
import test.constants as T import test.constants as T
import tools.file_tool import tools.file_tool
import model.application import model.application
import tools.data_const as D
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
@ -65,7 +66,7 @@ class MyTestCase(unittest.TestCase):
application = model.application.Application(job) application = model.application.Application(job)
name = "TESTAPP" name = "TESTAPP"
actproject = application.read_entity(job, name) actproject = application.read_entity(job, name)
self.assertEqual(getattr(actproject, model.application.FIELD_NAME), name) self.assertEqual(getattr(actproject, D.FIELD_NAME), name)
self.assertRaises(Exception, application.read_entity, job, "xyzxyz") self.assertRaises(Exception, application.read_entity, job, "xyzxyz")
# #
#actproject = component.select_entity(job, name) #actproject = component.select_entity(job, name)

3
test/test_21environment.py

@ -11,6 +11,7 @@ import test.constants as T
import tools.file_tool import tools.file_tool
import model.entity import model.entity
import model.environment import model.environment
import tools.data_const as D
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
@ -63,7 +64,7 @@ class MyTestCase(unittest.TestCase):
environment = model.environment.Environment(job, "TESTPROJ") environment = model.environment.Environment(job, "TESTPROJ")
name = "ENV01" name = "ENV01"
actrelease = environment.read_entity(job, name) actrelease = environment.read_entity(job, name)
self.assertEqual(getattr(actrelease, model.environment.FIELD_NAME), name) self.assertEqual(getattr(actrelease, D.FIELD_NAME), name)
self.assertRaises(Exception, environment.read_entity, job, "xyzxyz") self.assertRaises(Exception, environment.read_entity, job, "xyzxyz")
# #
#actenvironment = environment.select_entity(job, name) #actenvironment = environment.select_entity(job, name)

3
test/test_22component.py

@ -9,6 +9,7 @@ import basic.constants as B
import test.constants as T import test.constants as T
import model.component import model.component
import model.entity import model.entity
import tools.data_const as D
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
@ -61,7 +62,7 @@ class MyTestCase(unittest.TestCase):
component = model.component.Component(job) component = model.component.Component(job)
name = "testprd" name = "testprd"
actproject = component.read_entity(job, name) actproject = component.read_entity(job, name)
self.assertEqual(getattr(actproject, model.component.FIELD_NAME), name) self.assertEqual(getattr(actproject, D.FIELD_NAME), name)
self.assertRaises(Exception, component.read_entity, job, "xyzxyz") self.assertRaises(Exception, component.read_entity, job, "xyzxyz")
# #
#actproject = component.select_entity(job, name) #actproject = component.select_entity(job, name)

7
tools/file_type.py

@ -307,9 +307,12 @@ def check_nodes(job, config: dict, checkNodes: dict):
mustNodes = checkNodes[MUST_NODES] mustNodes = checkNodes[MUST_NODES]
mustntNodes = checkNodes[MUSTNT_NODES] mustntNodes = checkNodes[MUSTNT_NODES]
optionalNodes = checkNodes[OPT_NODES] optionalNodes = checkNodes[OPT_NODES]
a = str(config["_path"]).split(os.path.sep) if B.DATA_NODE_PATH in config:
a = str(config[B.DATA_NODE_PATH]).split(os.path.sep)
b = a[-1].split(".") b = a[-1].split(".")
path = config["_path"] path = config[B.DATA_NODE_PATH]
else:
path = ""
""" """
if b[0] in config: if b[0] in config:
config = config[b[0]] config = config[b[0]]

Loading…
Cancel
Save