Browse Source

table.get_schema

refactor
Ulrich 1 year ago
parent
commit
78a68a9fce
  1. 5
      basic/constants.py
  2. 4
      model/ap_application.csv
  3. 2
      model/ap_component.csv
  4. 2
      model/ap_project.csv
  5. 7
      model/application.py
  6. 7
      model/co_artifact.csv
  7. 7
      model/co_step.csv
  8. 11
      model/co_table.csv
  9. 2
      model/component.csv
  10. 6
      model/datatable.csv
  11. 4
      model/en_component.csv
  12. 4
      model/en_project.csv
  13. 2
      model/environment.csv
  14. 2
      model/story.csv
  15. 43
      model/table.py
  16. 3
      model/tc_step.csv
  17. 3
      model/tc_story.csv
  18. 5
      model/tc_table.csv
  19. 2
      model/testcase.csv
  20. 2
      model/testplan.csv
  21. 4
      model/testreport.csv
  22. 2
      model/testsuite.csv
  23. 3
      model/tp_testsuite.csv
  24. 5
      model/tr_artifact.csv
  25. 3
      model/ts_testcase.csv
  26. 3
      model/ts_usecase.csv
  27. 2
      model/usecase.csv
  28. 2
      model/user.csv
  29. 4
      model/variant.csv
  30. 112
      test/test_14table.py
  31. 10
      tools/config_tool.py
  32. 3
      tools/data_const.py
  33. 5
      tools/dbrel_tool.py
  34. 3
      tools/path_const.py

5
basic/constants.py

@ -193,11 +193,14 @@ SUBJECT_STORY = "story"
SUBJECT_STORIES = "stories"
SUBJECT_DESCRIPTION = "description" # --> MAIN-ATTR
SUBJECT_REFERENCE = "reference" # --> MAIN-ATTR
LIST_SUBJECTS = [SUBJECT_APPS, SUBJECT_ARTIFACT, SUBJECT_COMPS, SUBJECT_PROJECTS]
SUBJECT_STEP = "step"
SUBJECT_STEPS = "steps"
SUBJECT_DATATABLE = "table"
SUBJECT_DATATABLES = SUBJECT_DATATABLE + "s"
# List of persistent models
LIST_SUBJECTS = [SUBJECT_PROJECTS, SUBJECT_APPS, SUBJECT_USECASES, SUBJECT_VARIANTS, SUBJECT_RELS, SUBJECT_STORIES,
SUBJECT_TESTPLANS, SUBJECT_TESTSUITES, SUBJECT_TESTCASES, SUBJECT_STEPS, SUBJECT_DATATABLES,
SUBJECT_ENVIRONMENTS, SUBJECT_COMPS, SUBJECT_ARTIFACTS]
# --Topic -----------------------------------------------------
# _____ _

4
model/ap_application.csv

@ -1,4 +1,6 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:ap_application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;apappid;pk;vchar(256);N;;;;;;
;apid;int;vchar(256);I;;;;;;
;component;str;vchar(256);I;;;;;;
;appid;int;vchar(256);I;;;;;;

1 table:ap_application _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:ap_application table:ap_application _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 apappid apappid pk pk vchar(256) vchar(256) N N
5 apid apid int int vchar(256) vchar(256) I I
6 component appid str int vchar(256) vchar(256) I I

2
model/ap_component.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:ap_component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;apcomid;pk;int;N;;;;;;
;apid;int;int;I;;;;;;

1 table:ap_component _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:ap_component table:ap_component _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 apcomid apcomid pk pk int int N N
5 apid apid int int int int I I

2
model/ap_project.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:ap_project;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;pjid;pk;int;N;;;;;;
;apid;int;int;I;;;;;;

1 table:ap_project _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:ap_project table:ap_project _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 pjid pjid pk pk int int N N
5 apid apid int int int int I I

7
model/application.py

@ -434,10 +434,3 @@ class Application_old(model.entity.Entity):
def writeEntity(self):
pass
def get_schema(self, tableName="", tableObject=None):
"""
ersetzt durch testserver.createDB
:return:
"""
return ""

7
model/co_artifact.csv

@ -1,5 +1,8 @@
table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcid;int;integer;I;;;T:1;;;
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:co_artifact;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;coartid;pk;int;N;;;;;;
;coid;int;integer;I;;;T:1;;;
;stid;int;integer;I;;;T:2;;;
;story;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;

1 table:tc_story _type _field ctlg type format index generic aggregat key acceptance alias description
2 _key tcid _field int integer I T:1
3 table:co_artifact _field type format index generic aggregat key acceptance alias description
4 coartid pk int N
5 coid int integer I T:1
6 stid stid int int integer integer I I T:2 T:2
7 story story str str vchar(256) vchar(256) I I
8 description description string string vchar(256) vchar(256) N N

7
model/co_step.csv

@ -1,5 +1,8 @@
table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcid;int;integer;I;;;T:1;;;
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:co_step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;costpid;pk;int;N;;;;;;
;coid;int;integer;I;;;T:1;;;
;stid;int;integer;I;;;T:2;;;
;story;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;

1 table:tc_story _type _field ctlg type format index generic aggregat key acceptance alias description
2 _key tcid _field int integer I T:1
3 table:co_step _field type format index generic aggregat key acceptance alias description
4 costpid pk int N
5 coid int integer I T:1
6 stid stid int int integer integer I I T:2 T:2
7 story story str str vchar(256) vchar(256) I I
8 description description string string vchar(256) vchar(256) N N

11
model/co_table.csv

@ -1,7 +1,10 @@
table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcid;int;integer;I;;;T:1;;;
;stid;int;integer;I;;;T:2;;;
;story;str;vchar(256);I;;;;;;
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:co_table;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;codtbid;pk;int;N;;;;;;
;coid;int;integer;I;;;T:1;;;
;dtid;int;integer;I;;;T:2;;;
;datatable;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;
;acceptcriteria;str;clob;N;;;;;;

1 table:tc_story _type _field ctlg type format index generic aggregat key acceptance alias description
2 _key tcid _field int integer I T:1
3 table:co_table stid _field int type integer format I index generic aggregat T:2 key acceptance alias description
4 story codtbid str pk vchar(256) int I N
5 coid int integer I T:1
6 dtid int integer I T:2
7 datatable str vchar(256) I
8 description description string string vchar(256) vchar(256) N N
9 reference reference str str vchar(256) vchar(256) N N
10 acceptcriteria acceptcriteria str str clob clob N N

2
model/component.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;coid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:component generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:component _field _field type type format format index index table:component generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 coid coid pk pk int int N N
5 name name str str vchar(256) vchar(256) I I

6
model/datatable.csv

@ -1,5 +1,7 @@
table:table;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tbid;pk;integer;N;;;T:1;;;
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:datatable;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;dtid;pk;integer;N;;;T:1;;;
;name;str;vchar(256);I;;;F:1;;;
;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;story

1 _type _field ctlg type format index table:table generic key aggregat alias acceptance description
2 _key tbid _field pk integer N T:1
3 table:datatable _field type format index generic aggregat key acceptance alias description
4 dtid pk integer N T:1
5 name name str str vchar(256) vchar(256) I I F:1 F:1
6 description description string string vchar(256) vchar(256) N N
7 reference reference str str vchar(256) vchar(256) N N story story

4
model/en_component.csv

@ -1,5 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:en_component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;encomid;pk;vchar(256);N;;;;;;
;encomid;pk;int;N;;;;;;
;enid;int;vchar(256);I;;;;;;
;component;str;vchar(256);I;;;;;;
;instance;int;vchar(256);N;;;;;;

1 _type _field ctlg type format index table:en_component generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:en_component _field _field type type format format index index table:en_component generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 encomid encomid pk pk vchar(256) int N N
5 enid enid int int vchar(256) vchar(256) I I
6 component component str str vchar(256) vchar(256) I I
7 instance instance int int vchar(256) vchar(256) N N

4
model/en_project.csv

@ -1,4 +1,6 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:en_project;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;enproid;pk;vchar(256);N;;;;;;
;enproid;pk;int;N;;;;;;
;enid;int;vchar(256);I;;;;;;
;project;str;vchar(256);I;;;;;;

1 table:en_project _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:en_project table:en_project _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 enproid enproid pk pk vchar(256) int N N
5 enid enid int int vchar(256) vchar(256) I I
6 project project str str vchar(256) vchar(256) I I

2
model/environment.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:environment;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;enid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:environment generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:environment _field _field type type format format index index table:environment generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 enid enid pk pk int int N N
5 name name str str vchar(256) vchar(256) I I

2
model/story.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;stid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:story generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:story _field _field type type format format index index table:story generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 stid stid pk pk int int N N
5 name name str str vchar(256) vchar(256) I I

43
model/table.py

@ -23,7 +23,7 @@ FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_APPLICATION = B.SUBJECT_APP
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS]
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS]
LIST_SUBTABLES = {}
@ -63,28 +63,30 @@ def select_tables(job, project="", application="", component=""):
return outList
class Table(model.entity.Entity):
"""
table-object as part of a database
in different of datatable it is neither a concrete table in the automation-model
nor a concrete table in the system-model
it is an abstract super-class in order to relation to the database-management-system
"""
tbid = 0
name = ""
project = ""
application = ""
component = ""
fieldnames = []
fielddef = {}
def __init__(self, job, project="", application="", component="", name=""):
def __init__(self, job, project="", name=""):
"""
to be initialized by readSpec
to be initialized
:param job:
"""
self.job = job
if len(project) > 1:
if project != "":
self.project = project
if len(application) > 1:
self.application = application
if len(component) > 1:
self.component = component
if len(name) > 1:
self.read_ddl(job, name)
def set_object(self, project, name):
self.project = project
self.name = name
def get_schema(self, tableName="", tableObject=None):
"""
@ -138,13 +140,22 @@ class Table(model.entity.Entity):
: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)
if project == B.ATTR_INST_TESTSERVER:
path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_PROGRAM], P.ATTR_PATH_MODEL)
else:
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 read_entity(self, job, name, project=""):
if project == B.ATTR_INST_TESTSERVER:
config = self.getConfig(job, P.KEY_MODEL, name, tools.config_tool.get_plain_filename(job, name))
else:
config = self.getConfig(job, P.KEY_CATALOG, name, tools.config_tool.get_plain_filename(job, name))
self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
self.fielddef = self.key
self.fieldnames = list(self.key.keys())
return self
def getFieldList(self):
"""

3
model/tc_step.csv

@ -1,4 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:tc_step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcstpid;pk;integer;N;;;;;;
;tcid;int;integer;I;;;T:1;;;
;spid;int;integer;I;;;T:2;;;
;description;string;vchar(256);N;;;;;;

1 table:tc_step _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:tc_step table:tc_step _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tcstpid pk integer N
5 tcid tcid int int integer integer I I T:1 T:1
6 spid spid int int integer integer I I T:2 T:2
7 description description string string vchar(256) vchar(256) N N

3
model/tc_story.csv

@ -1,4 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcstrid;pk;integer;N;;;T:1;;;
;tcid;int;integer;I;;;T:1;;;
;stid;int;integer;I;;;T:2;;;
;story;str;vchar(256);I;;;;;;

1 table:tc_story _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:tc_story table:tc_story _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tcstrid pk integer N T:1
5 tcid tcid int int integer integer I I T:1 T:1
6 stid stid int int integer integer I I T:2 T:2
7 story story str str vchar(256) vchar(256) I I

5
model/tc_table.csv

@ -1,5 +1,8 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:tc_table;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcdtbid;pk;integer;N;;;;;;
;tcid;int;integer;I;;;T:1;;;
;tbid;int;integer;I;;;T:2;;;
;dtid;int;integer;I;;;T:2;;;
;count;int;int;N;;;;;;
;refdate;date;date;N;;;;;;

1 table:tc_table _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:tc_table table:tc_table _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tcdtbid pk integer N
5 tcid tcid int int integer integer I I T:1 T:1
6 tbid dtid int int integer integer I I T:2 T:2
7 count count int int int int N N
8 refdate refdate date date date date N N

2
model/testcase.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:testcase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcid;pk;integer;N;;;T:1;;;
;name;str;vchar(256);I;;;F:1;;;

1 _type _field ctlg type format index table:testcase generic key aggregat alias acceptance description
1 _type ctlg
2 _key _field
3 table:testcase _field _field type type format format index index table:testcase generic generic aggregat key key aggregat acceptance alias acceptance alias description description
4 tcid tcid pk pk integer integer N N T:1 T:1
5 name name str str vchar(256) vchar(256) I I F:1 F:1

2
model/testplan.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:testplan;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tpid;pk;integer;N;;;T:1;;;
;name;str;vchar(256);I;;;F:1;;;

1 _type _field ctlg type format index table:testplan generic key aggregat alias acceptance description
1 _type ctlg
2 _key _field
3 table:testplan _field _field type type format format index index table:testplan generic generic aggregat key key aggregat acceptance alias acceptance alias description description
4 tpid tpid pk pk integer integer N N T:1 T:1
5 name name str str vchar(256) vchar(256) I I F:1 F:1

4
model/testreport.csv

@ -1,5 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:testreport;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tcid;pk;integer;N;;;T:1;;;
;trid;pk;integer;N;;;T:1;;;
;name;str;vchar(256);I;;;F:1;;;
;description;string;vchar(256);N;;;;;;
;project;string;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:testreport generic key aggregat acceptance description alias
1 _type ctlg
2 _key _field
3 table:testreport _field _field type type format format index index table:testreport generic generic aggregat key key aggregat acceptance acceptance alias description alias description
4 tcid trid pk pk integer integer N N T:1 T:1
5 name name str str vchar(256) vchar(256) I I F:1 F:1
6 description description string string vchar(256) vchar(256) N N
7 project project string string vchar(256) vchar(256) I I

2
model/testsuite.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:testsuite;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tsid;pk;integer;N;;;T:1;;;
;name;str;vchar(256);I;;;F:1;;;

1 _type _field ctlg type format index table:testsuite generic key aggregat alias acceptance description
1 _type ctlg
2 _key _field
3 table:testsuite _field _field type type format format index index table:testsuite generic generic aggregat key key aggregat acceptance alias acceptance alias description description
4 tsid tsid pk pk integer integer N N T:1 T:1
5 name name str str vchar(256) vchar(256) I I F:1 F:1

3
model/tp_testsuite.csv

@ -1,4 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:tp_testsuite;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tptsuid;pk;integer;N;;;;;;
;tpid;int;integer;I;;;T:1;;;
;tsid;int;integer;I;;;T:2;;;
;description;string;vchar(256);N;;;;;;

1 table:tp_testsuite _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:tp_testsuite table:tp_testsuite _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tptsuid pk integer N
5 tpid tpid int int integer integer I I T:1 T:1
6 tsid tsid int int integer integer I I T:2 T:2
7 description description string string vchar(256) vchar(256) N N

5
model/tr_artifact.csv

@ -1,6 +1,9 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:tr_artifact;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;trartid;pk;integer;N;;;;;;
;trid;int;integer;I;;;T:1;;;
;afid;int;integer;I;;;T:2;;;
;arid;int;integer;I;;;T:2;;;
;result;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;
;reference;str;vchar(256);N;;;;;;

1 table:tr_artifact _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:tr_artifact table:tr_artifact _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 trartid pk integer N
5 trid trid int int integer integer I I T:1 T:1
6 afid arid int int integer integer I I T:2 T:2
7 result result str str vchar(256) vchar(256) I I
8 description description string string vchar(256) vchar(256) N N
9 reference reference str str vchar(256) vchar(256) N N

3
model/ts_testcase.csv

@ -1,4 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:ts_testcase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tstcsid;pk;integer;N;;;;;;
;tsid;int;integer;I;;;T:1;;;
;tcid;int;integer;I;;;T:2;;;
;description;string;vchar(256);N;;;;;;

1 table:ts_testcase _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:ts_testcase table:ts_testcase _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tstcsid pk integer N
5 tsid tsid int int integer integer I I T:1 T:1
6 tcid tcid int int integer integer I I T:2 T:2
7 description description string string vchar(256) vchar(256) N N

3
model/ts_usecase.csv

@ -1,4 +1,7 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:ts_usecase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;tsucsid;pk;integer;N;;;;;;
;tsid;int;integer;I;;;T:1;;;
;ucid;int;integer;I;;;T:2;;;
;description;string;vchar(256);N;;;;;;

1 table:ts_usecase _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:ts_usecase table:ts_usecase _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 tsucsid pk integer N
5 tsid tsid int int integer integer I I T:1 T:1
6 ucid ucid int int integer integer I I T:2 T:2
7 description description string string vchar(256) vchar(256) N N

2
model/usecase.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:usecase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;ucid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;

1 _type _field ctlg type format index table:usecase generic aggregat key acceptance description alias
1 _type ctlg
2 _key _field
3 table:usecase _field _field type type format format index index table:usecase generic generic aggregat aggregat key key acceptance acceptance alias description alias description
4 ucid ucid pk pk int int N N
5 name name str str vchar(256) vchar(256) I I

2
model/user.csv

@ -1,3 +1,5 @@
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:user;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;id;pk;autoint;N;;;T:1;;;
;username;str;vchar(256);N;;;F:1;;;

1 table:user _type _field ctlg type format index generic aggregat key acceptance alias description
1 _type ctlg
2 _key _field
3 table:user table:user _field _field type type format format index index generic generic aggregat aggregat key key acceptance acceptance alias alias description description
4 id id pk pk autoint autoint N N T:1 T:1
5 username username str str vchar(256) vchar(256) N N F:1 F:1

4
model/variant.csv

@ -1,4 +1,6 @@
table:step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
_type;ctlg;;;;;;;;;
_key;_field;;;;;;;;;
table:variant;_field;type;format;index;generic;aggregat;key;acceptance;alias;description
;vrid;pk;int;N;;;;;;
;name;str;vchar(256);I;;;;;;
;description;string;vchar(256);N;;;;;;

1 _type _field ctlg type format index table:step generic aggregat key acceptance description alias
2 _key _field
3 table:variant _field type format index generic aggregat key acceptance alias description
4 vrid vrid pk pk int int N N
5 name name str str vchar(256) vchar(256) I I
6 description description string string vchar(256) vchar(256) N N

112
test/test_14table.py

@ -0,0 +1,112 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import unittest
import inspect
import test.testtools
import basic.constants as B
import test.constants as T
import model.table
import model.entity
HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity",
"test_13writeEntity", "test_14insertEntity",
"test_20getSchema"]
TEST_FUNCTIONS = ["test_20getSchema"]
PROGRAM_NAME = "clean_workspace"
class MyTestCase(unittest.TestCase):
mymsg = "--------------------------------------------------------------"
def test_10getEntityNames(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
entityNames = table.read_unique_names(job, "", "", "", {})
self.assertEqual(type(entityNames), list)
entityNames = table.read_unique_names(job, B.ATTR_INST_TESTSERVER, "", "", {})
self.assertEqual(type(entityNames), list)
#entityNames = project.select_unique_names(job, "", "", "", {})
#self.assertEquals(type(entityNames), list)
def test_11getEntities(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
entityNames = []
entityNames = table.get_entities(job, storage=model.entity.STORAGE_FILE)
self.assertEqual(type(entityNames), list)
#entityNames = table.get_entities(job, storage=model.entity.STORAGE_DB)
#self.assertEqual(type(entityNames), list)
def test_12getEntity(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, "TESTPROJ")
name = "adress"
acttable = table.read_entity(job, name)
self.assertEqual(getattr(acttable, model.table.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
#
table = model.table.Table(job, B.ATTR_INST_TESTSERVER)
name = B.SUBJECT_APP
acttable = table.read_entity(job, name, project=B.ATTR_INST_TESTSERVER)
self.assertEqual(getattr(acttable, model.table.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
#
table = model.table.Table(job, B.ATTR_INST_TESTSERVER)
name = "ap_application"
acttable = table.read_entity(job, name, project=B.ATTR_INST_TESTSERVER)
self.assertEqual(getattr(acttable, model.table.FIELD_NAME), name)
self.assertRaises(Exception, table.read_entity, job, "xyzxyz")
def test_20getSchema(self):
global mymsg
global jobObject
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
job = test.testtools.getJob()
table = model.table.Table(job, B.ATTR_INST_TESTSERVER)
entityNames = table.read_unique_names(job, B.ATTR_INST_TESTSERVER, "", "", {})
name = "tc_table"
print(name)
acttable = table.read_entity(job, name, project=B.ATTR_INST_TESTSERVER)
schema = acttable.get_schema(name)
print(schema)
self.assertEqual("CREATE TABLE", schema[:12])
self.assertIn(name, schema)
for name in entityNames:
print(name)
acttable = table.read_entity(job, name, project=B.ATTR_INST_TESTSERVER)
schema = acttable.get_schema(name)
print(schema)
self.assertEqual("CREATE TABLE", schema[:12])
self.assertIn("PRIMARY KEY", schema)
self.assertIn(name, schema)
if __name__ == '__main__':
unittest.main()

10
tools/config_tool.py

@ -88,6 +88,8 @@ def select_config_path(job, modul, name, subname=""):
return getEnvironmentPath(job, name)
elif modul == P.KEY_USER:
return getUserPath(job, name)
elif modul == P.KEY_MODEL:
return getModelPath(job, name)
else:
pathname = tools.path_tool.compose_path(job, P.P_TCPARFILE)
if verify: job.debug(verify, "7 " + pathname)
@ -236,6 +238,14 @@ def getUserPath(job, name):
return pathname
return None
def getModelPath(job, name):
for ext in CONFIG_FORMAT:
pathname = os.path.join(job.conf[B.TOPIC_PATH][P.ATTR_PATH_PROGRAM], P.ATTR_PATH_MODEL, name + "." + ext)
if os.path.exists(pathname):
return pathname
return None
def get_plain_filename(job, path):
"""
the function extracts the plain filename without directory-name and extension

3
tools/data_const.py

@ -15,6 +15,9 @@ TYPE_FLOAT = "float"
TYPE_DOUBLE = "double"
TYPE_DATE = "date"
TYPE_TIME = "time"
TYPE_CLOB = "clob"
TYPE_JLOB = "jlob"
TYPE_XLOB = "xlob"
TYPE_PK = "pk"
TYPE_AUTOINT = "autoint"

5
tools/dbrel_tool.py

@ -7,7 +7,8 @@
import tools.db_abstract
import mysql.connector
import basic.constants as B
import utils.data_const as D
import tools.data_const as D
class DbFcts(tools.db_abstract.DbFcts):
"""
This interface defines each necessary connection to any kind of database.
@ -92,6 +93,8 @@ class DbFcts(tools.db_abstract.DbFcts):
return attr + " text"
elif atype == D.TYPE_INT:
return attr + " integer"
elif atype == D.TYPE_DATE:
return attr + " datetime"
elif atype == D.TYPE_TIME:
return attr + " datetime"

3
tools/path_const.py

@ -14,6 +14,7 @@ KEY_REFFILE = "reffile"
KEY_TESTCASE = "tc"
KEY_TESTSUITE = "ts"
KEY_CATALOG = "catalog"
KEY_MODEL = "model"
KEY_USER = "user"
KEY_DEBUGNAME = "debugname"
KEY_LOGNAME = "logname"
@ -82,7 +83,7 @@ ATTR_PATH_PROGRAM = "program"
""" This constant defines the program-folder in the workspace """
ATTR_PATH_COMPONENTS = "components"
""" This constant defines the program-folder in the workspace """
ATTR_PATH_MODEL = "model"
ATTR_PATH_MODEL = KEY_MODEL
""" This constant defines the folder in model """
ATTR_PATH_ENV = "environment"
""" This constant defines the folder in testing-filesystem, used for configs related to environments """

Loading…
Cancel
Save