Browse Source

refactor: devide table - datatable

refactor
Ulrich 1 year ago
parent
commit
8346e1eadc
  1. 27
      model/datatable.py
  2. 3
      model/testcase.py
  3. 12
      test/test_29datatable.py

27
model/datatable.py

@ -2,8 +2,14 @@
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import os
import basic.constants as B
import model.entity
import tools.path_const as P
import tools.data_const as D
import tools.config_tool
import tools.file_tool
import tools.git_tool
FIELD_ID = "dtid"
FIELD_NAME = "name"
@ -30,6 +36,27 @@ class Datatable(model.entity.Entity):
:param job:
"""
self.job = job
if project != "":
self.project = project
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
:param job:
:param opt. project: select-criteria if used and defined
:param opt. application: select-criteria if used and defined
:param opt. gran: granularity values testcase / testsuite / testplan
:param opt. args additional args
:return: list of entity-names
"""
path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS], P.KEY_CATALOG, P.VAL_TABLES)
outList = self.getDirlist(job, path, "csv")
return outList
def read_entity(self, job, name):
config = self.getConfig(job, P.KEY_CATALOG, name, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
def getFieldList(self):
"""

3
model/testcase.py

@ -18,7 +18,6 @@ import model.entity
import model.story
import model.datatable
import model.step
import model.table
TABLE_NAMES = ["application", "ap_project", "ap_component"]
STORAGES = [model.entity.STORAGE_FILE, model.entity.STORAGE_DB]
@ -206,7 +205,7 @@ class Testcase(model.entity.Entity):
pass
if B.DATA_NODE_TABLES in tdata:
for t in tdata[B.DATA_NODE_TABLES]:
table = model.table.Table(job, project=job.par.project, name=t)
table = model.datatable.Datatable(job, project=job.par.project, name=t)
pass
# for o in tdata[B.option
# header = tdata[B.DATA_NODE_STEPS][] LIST

12
test/test_27table.py → test/test_29datatable.py

@ -9,7 +9,7 @@ import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.table
import model.datatable
import model.entity
HOME_PATH = test.constants.HOME_PATH
@ -31,9 +31,9 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
table = model.datatable.Datatable(job, "TESTPROJ")
entityNames = table.read_unique_names(job, "", "", "", {})
self.assertEquals(type(entityNames), list)
self.assertEqual(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEquals(type(entityNames), list)
@ -45,7 +45,7 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
table = model.datatable.Datatable(job, "TESTPROJ")
entityNames = []
entityNames = table.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
@ -60,10 +60,10 @@ class MyTestCase(unittest.TestCase):
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
table = model.datatable.Datatable(job, "TESTPROJ")
name = "adress"
acttable = table.read_entity(job, name)
self.assertEqual(getattr(acttable, model.table.FIELD_NAME), name)
self.assertEqual(getattr(acttable, model.datatable.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
#
#actrelease = release.select_entity(job, name)
Loading…
Cancel
Save