diff --git a/basic/constants.py b/basic/constants.py index 7c0fc7d..c0a6dbf 100644 --- a/basic/constants.py +++ b/basic/constants.py @@ -156,7 +156,7 @@ topics relating to the domain are: SUBJECT_PROJECT = "project" SUBJECT_PROJECTS = SUBJECT_PROJECT + "s" SUBJECT_APP = "application" -SUBJECT_APPS = "applications" # +SUBJECT_APPS = SUBJECT_APP+"s" # SUBJECT_COMP = "component" SUBJECT_COMPS = SUBJECT_COMP + "s" SUBJECT_USECASE = "usecase" @@ -195,6 +195,8 @@ 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" # --Topic ----------------------------------------------------- # _____ _ @@ -335,7 +337,8 @@ DATA_NODE_PAR = "par" DATA_NODE_CATALOG = "_catalog" DATA_NODE_ROW = "_row" DATA_NODE_SUBTABLES = "subtables" # ?? SUBJECT -LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, +DATA_NODE_TOPICS = "_topics" +LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, DATA_NODE_TOPICS, DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW] # -- Parameter ------------------------------------------------ diff --git a/model/application.py b/model/application.py index d9f0c04..3c8a0a4 100644 --- a/model/application.py +++ b/model/application.py @@ -29,6 +29,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE FIELD_PROJECT = B.SUBJECT_PROJECT LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] SUB_COMPS = B.SUBJECT_COMPS SUB_APPS = B.SUBJECT_APPS @@ -263,7 +264,17 @@ class Application(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES + class Application_old(model.entity.Entity): table = "application" diff --git a/model/table.csv b/model/datatable.csv similarity index 100% rename from model/table.csv rename to model/datatable.csv diff --git a/model/datatable.py b/model/datatable.py new file mode 100644 index 0000000..c9fa25e --- /dev/null +++ b/model/datatable.py @@ -0,0 +1,42 @@ +# --------------------------------------------------------------------------------------------------------- +# Author : Ulrich Carmesin +# Source : gitea.ucarmesin.de +# --------------------------------------------------------------------------------------------------------- +import basic.constants as B +import model.entity + +FIELD_ID = "dtid" +FIELD_NAME = "name" +FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION +FIELD_REFERENCE = B.SUBJECT_REFERENCE +FIELD_COMPONENT = B.SUBJECT_COMP +FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES +FIELD_HEADER = "" +LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT] +LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS] + +LIST_SUBTABLES = {} + +class Datatable(model.entity.Entity): + dcid = 0 + document = "" + description = "" + project = "" + reference = "" + + def __init__(self, job, project="", name=""): + """ + to be initialized by readSpec + :param job: + """ + self.job = job + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES + diff --git a/model/document.py b/model/document.py deleted file mode 100644 index cc564b0..0000000 --- a/model/document.py +++ /dev/null @@ -1,20 +0,0 @@ -# --------------------------------------------------------------------------------------------------------- -# Author : Ulrich Carmesin -# Source : gitea.ucarmesin.de -# --------------------------------------------------------------------------------------------------------- -import basic.constants as B -import model.entity - -class Document(model.entity.Entity): - dcid = 0 - document = "" - description = "" - project = "" - reference = "" - - def __init__(self, job, project="", name=""): - """ - to be initialized by readSpec - :param job: - """ - self.job = job diff --git a/model/entity.py b/model/entity.py index 8df95ee..22a68e1 100644 --- a/model/entity.py +++ b/model/entity.py @@ -2,11 +2,13 @@ import getpass import os import re import basic.toolHandling +import model.factory # import model.entity import tools.data_const as D import tools.path_const as P import basic.constants as B import tools.config_tool +import tools.data_tool import tools.date_tool import tools.file_tool @@ -297,32 +299,56 @@ class Entity: outList.append(k[:-len(ext)-1]) return outList - def setAttributes(self, config, rootname, fields, subjects): + def setAttributes(self, job, config, rootname, fields, nodes, subjects): + """ + it sets the attributes of config into the entity-object + :param job: + :param config: dictionary of readed specification resp. configuration + :param rootname: rootname of config + :param fields: list of field-names, the model-const LIST_FIELDS + :param nodes: list of node-names, the model-const LIST_NODES + :param subjects: list of subtables-names, the model-const LIST_SUBTABLES + :return: + """ + setattr(self, D.FIELD_NAME, rootname) """ 2023-05 """ - for k in fields: - if k not in config[rootname]: - for l in config[rootname]: - if l[1:] == k: - setattr(self, k, config[rootname][l]) - break + for k in fields + nodes: + key = tools.data_tool.getExistKeyword(k, config[rootname]) + if key in ["", D.FIELD_NAME, D.FIELD_PROJECT]: continue - setattr(self, k, config[rootname][k]) + setattr(self, k, config[rootname][key]) for k in subjects: - if k not in config[rootname]: - for l in config[rootname]: - if l[1:] == k: - setattr(self, k, config[rootname][l]) - break + objects = {} + key = tools.data_tool.getExistKeyword(k, config[rootname]) + if key == "": continue - setattr(self, k, config[rootname][k]) + for o in config[rootname][key]: + args = {} + args[k] = config[rootname][key][o] + objects[o] = model.factory.get_entity_object(self.job, k, args) + setattr(self, k, objects) topics = {} - for k in B.LIST_TOPIC_NODES: - if k in config[rootname]: - topics[k] = config[rootname][k] - if len(topics) > 0: - setattr(self, "topics", topics) + key = tools.data_tool.getExistKeyword(B.DATA_NODE_TOPICS, config[rootname]) + if key != "": + for k in B.LIST_TOPIC_NODES: + if k in config[rootname][key]: + topics[k] = config[rootname][key][k] + setattr(self, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS), topics) return self + def getFieldList(self): + return [] + + def getNodeList(self): + return [] + + def getSubtableList(self): + return {} + + def setSubtable(self, job, subtable, sublist): + outDict = {} + for k in sublist: + pass def getDbAttr(self, job): out = {} diff --git a/model/environment.py b/model/environment.py index 84ec18b..96c082f 100644 --- a/model/environment.py +++ b/model/environment.py @@ -22,6 +22,7 @@ FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES] """ list of object-attributes """ LIST_SUBTABLES = [B.SUBJECT_COMPS, B.SUBJECT_PROJECTS] +LIST_NODES = [B.NODE_ATTRIBUTES] FILE_EXTENSION = D.DFILE_TYPE_YML UNIQUE_FIELDS = [FIELD_NAME] @@ -104,5 +105,5 @@ class Environment(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_ENV, name, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) diff --git a/model/factory.py b/model/factory.py index 46809ae..0854c70 100644 --- a/model/factory.py +++ b/model/factory.py @@ -1,5 +1,27 @@ import model.entity +import basic.constants as B +def get_entity_object(job, name, args): + if name in B.SUBJECT_STEPS: + entity = getStep(job) + elif name in B.SUBJECT_STORIES: + entity = getStory(job) + elif name in B.SUBJECT_VARIANTS: + entity = getVariant(job) + elif name in B.SUBJECT_DATATABLES: + entity = getDatatable(job) + elif name in B.SUBJECT_APPS: + entity = getApplication(job) + elif name in B.SUBJECT_COMPS: + entity = getComponent(job) + elif name in B.SUBJECT_TESTCASES: + entity = getTestcase(job) + elif name in B.SUBJECT_TESTSUITES: + entity = getTestsuite(job) + else: + return None + entity.setAttributes(job, args, name, entity.getFieldList(), entity.getNodeList(), entity.getSubtableList()) + return entity def getEnvironment(job=None): import model.environment @@ -24,3 +46,24 @@ def getTestsuite(job=None, project="", application="", name=""): def getTestcase(job=None, project="", application="", name=""): import model.testcase return model.testcase.Testcase(job, project, name=name) + +def getStep(job=None, project="", name=""): + import model.step + return model.step.Step(job, project, name) + +def getStory(job=None, project="", name=""): + import model.story + return model.story.Story(job, project, name) + +def getUsecase(job=None, project="", name=""): + import model.usecase + return model.usecase.Usecase(job, project, name) + +def getVariant(job=None, project="", name=""): + import model.variant + return model.variant.Variant(job, project, name) + +def getDatatable(job=None, project="", name=""): + import model.datatable + return model.datatable.Datatable(job, project, name) + diff --git a/model/release.py b/model/release.py index 50a43e8..956e505 100644 --- a/model/release.py +++ b/model/release.py @@ -23,6 +23,7 @@ FIELD_APPLICATION = B.SUBJECT_APP FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] LIST_SUBTABLES = [] FILE_EXTENSION = D.DFILE_TYPE_CSV @@ -70,5 +71,13 @@ class Release(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_RELS, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/step.py b/model/step.py index 5b1a2f2..e1cc99b 100644 --- a/model/step.py +++ b/model/step.py @@ -23,6 +23,7 @@ FIELD_COMPONENT = B.SUBJECT_COMP FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_COMPONENT] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS] LIST_SUBTABLES = [] FILE_EXTENSION = D.DFILE_TYPE_YML @@ -62,16 +63,29 @@ FIELDS = { # start programs # start function # class Step(model.entity.Entity): - nr = 0 - name = "" - description = "" - project = "" - group = 0 - component = "" - fct = "" - tool = "" - toolname = "" - args = {} + """ + this class describes execution steps in a formal language = fields, + in testcase-specification it describe the start-point of an action, here the business information are specified like + * variant + * reference of program-step, sorting-nr, reference to testdata which are specified above + * entity which implements the action + * further business-arguments as json-string + the detailed steps (build the request, send the request, get the response, ..) are configured in the component + in sub-steps of the specified step, here the technical information are configured like + * topic and type which implements the detail-step + * further arguments inside the dict + """ + name = "" # variant + variant = "" + sortnr = 0 + """ sorting, alternative step may have the same sortnr, then the correct step is selected by program-variant """ + progstep = 0 + """ in order to filter the steps for specific program-executions """ + dataref = "" + component = "" # the name of the component or of the parameter "testcases" + arguments = {} + topic = "" # is set by component-configuration + type = "" # is set by component-configuration def __init__(self, job, project="", name="", obj=None): """ @@ -114,7 +128,7 @@ class Step(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) def rest_read(self, job, name): print("step read "+name) @@ -126,4 +140,13 @@ class Step(model.entity.Entity): raise Exception("Keine Komponente zu "+name+" definiert.") cm = basic.componentHandling.ComponentManager.getInstance(job) comp = cm.getComponent(variant["comp"]) - print(str(comp)) \ No newline at end of file + print(str(comp)) + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/story.py b/model/story.py index 48d2c13..8b3534b 100644 --- a/model/story.py +++ b/model/story.py @@ -20,7 +20,8 @@ FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES] """ list of object-attributes """ -LIST_SUBTABLES = [] +LIST_NODES = [B.NODE_ATTRIBUTES] +LIST_SUBTABLES = {} FILE_EXTENSION = D.DFILE_TYPE_CSV UNIQUE_FIELDS = [FIELD_NAME] @@ -65,5 +66,13 @@ class Story(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_STORIES, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/table.py b/model/table.py index 15ce9de..bdbc6ce 100644 --- a/model/table.py +++ b/model/table.py @@ -23,8 +23,9 @@ 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_SUBTABLES = [] +LIST_SUBTABLES = {} DEFAULT_FIELD = "" DEFAULT_TYPE = "string" @@ -143,7 +144,16 @@ class Table(model.entity.Entity): 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(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES def read_ddl(self, job, name): ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name) diff --git a/model/testcase.py b/model/testcase.py index 3c42e1c..263ff46 100644 --- a/model/testcase.py +++ b/model/testcase.py @@ -16,7 +16,7 @@ import tools.path_tool import tools.path_const as P import model.entity import model.story -import model.document +import model.datatable import model.step import model.table @@ -34,6 +34,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE FIELD_PROJECT = B.SUBJECT_PROJECT LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] SUB_USECASE = B.SUBJECT_USECASES SUB_STORIES = B.SUBJECT_STORIES @@ -121,26 +122,17 @@ class Testcase(model.entity.Entity): # r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") config = self.getConfig(job, P.KEY_TESTCASE, name, tools.config_tool.get_plain_filename(job, name)) self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) - """ - for k in LIST_SUBTABLES.keys(): - if not hasattr(self, k): - continue - pass - if "_"+k in config[name] and "_"+k+"-description" in LIST_SUB_DESCRIPT: - values = {} - if "_"+k+"-description" in config[name]: - for l in config[name]["_"+k]: - if l in config[name]["_"+k+"-description"]: - values[config[name]["_"+k][l]] = config[name]["_" + k + "-description"][l] - else: - values[config[name]["_"+k][l]] = "" - else: - for l in config[name]["_"+k]: - values[config[name]["_" + k][l]] = "" - setattr(self, k, values) - """ return self + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES + def xxread_entity(self, job, name): """ reads the entity from the file-system diff --git a/model/testplan.py b/model/testplan.py index ad54fa4..fc6edbf 100644 --- a/model/testplan.py +++ b/model/testplan.py @@ -8,6 +8,22 @@ import basic.toolHandling import tools.data_const as D import basic.constants as B import model.entity +import tools.config_tool + +FIELD_ID = "tcid" +FIELD_NAME = D.FIELD_NAME +FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION +FIELD_REFERENCE = B.SUBJECT_REFERENCE +FIELD_PROJECT = B.SUBJECT_PROJECT +FIELD_RELEASE = B.SUBJECT_REL +LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_RELEASE] +""" list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] + +LIST_SUBTABLES = { + B.SUBJECT_STEPS: [], + B.SUBJECT_TESTSUITES: [] +} class Testplan(model.entity.Entity): name = "" @@ -23,3 +39,21 @@ class Testplan(model.entity.Entity): """ self.job = job + def read_entity(self, job, name): + """ + reads the entity from the file-system + :param job: + :param name: + :return: + """ + config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, name)) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/testsuite.py b/model/testsuite.py index c55c55c..6f4a99c 100644 --- a/model/testsuite.py +++ b/model/testsuite.py @@ -28,6 +28,7 @@ FIELD_REFERENCE = B.SUBJECT_REFERENCE FIELD_PROJECT = B.SUBJECT_PROJECT LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] SUB_USECASE = B.SUBJECT_USECASES SUB_TESTCASES = B.SUBJECT_TESTCASES @@ -85,7 +86,7 @@ class Testsuite(model.entity.Entity): """ # r = tools.config_tool.select_config_path(job, P.KEY_TESTCASE, "TC0001") config = self.getConfig(job, P.KEY_TESTSUITE, name, tools.config_tool.get_plain_filename(job, name)) - self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + #self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) for k in LIST_SUBTABLES: if not hasattr(self, k): continue @@ -103,6 +104,14 @@ class Testsuite(model.entity.Entity): setattr(self, k, values) return self + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES def get_schema(self, tableName="", tableObject=None): #TODO veraltet diff --git a/model/topic.py b/model/topic.py new file mode 100644 index 0000000..e590777 --- /dev/null +++ b/model/topic.py @@ -0,0 +1,72 @@ +# --------------------------------------------------------------------------------------------------------- +# Author : Ulrich Carmesin +# Source : gitea.ucarmesin.de +# --------------------------------------------------------------------------------------------------------- +""" +spontanes Fliegengewicht, das aus einer der folgenden Contexte gebodlet wird. +step: + hier als umzusetzende Technik +artefact: + hier als umzusetzende Technik bei init oder collect +component: + als Superklasse zwecks Ererben fehlernder Attribute +environment: + als Superklasse zwecks Ererben fehlernder Attribute +in den jeweiligen technischen Elternklassenv werden die Attribute gesammelt und bei der Ausfuehrung komprimmiert. +Die so zusammen gesammelten Konfigurationen werden der jeweilgen Funktionsklasse uebergeben. +""" +import os +import basic.constants as B +import model.entity +import tools.path_const as P +import tools.data_tool +import tools.data_const as D + +TABLE_NAME = tools.data_tool.getSingularKeyword(B.DATA_NODE_TOPICS) +""" system-name for this entity """ +FIELD_ID = "toid" +FIELD_NAME = D.FIELD_NAME +LIST_FIELDS = [FIELD_ID, FIELD_NAME] +""" list of object-attributes """ +LIST_NODES = [] +LIST_SUBTABLES = {} + +component = "" +environment = "" +topic = "" # +""" one of B.LIST_TOPIC_NODES """ +type = "" # +""" one of the implemented Tools """ + +class Topic(model.entity.Entity): + name = "" + type = "" + attributes = "" + environment = "" + component = "" + + def __init__(self, job, environment, component, name=""): + """ + to be initialized by readSpec + """ + self.job = job + self.environment = environment + self.component = component + + def read_entity(self, job, name): + """ + reads the entity from the file-system + :param job: + :param name: + :return: + """ + config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, "") + + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/usecase.py b/model/usecase.py index aa31519..01904ab 100644 --- a/model/usecase.py +++ b/model/usecase.py @@ -21,6 +21,7 @@ FIELD_APPLICATION = B.SUBJECT_APP FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_APPLICATION, FIELD_ATTRIBUTES] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] LIST_SUBTABLES = [] FILE_EXTENSION = D.DFILE_TYPE_CSV @@ -68,5 +69,13 @@ class Usecase(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_CATALOG, B.SUBJECT_USECASES, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/model/user.py b/model/user.py index b80005f..dc06bb8 100644 --- a/model/user.py +++ b/model/user.py @@ -25,6 +25,8 @@ FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_ROLE = "role" LIST_FIELDS = [FIELD_ID, FIELD_ROLE, FIELD_PROJECT, FIELD_PASSWORD, FIELD_EMAIL, FIELD_FAMNAME, FIELD_NAME, FIELD_USERNAME] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] +LIST_SUBTABLES = {} FILE_EXTENSION = D.DFILE_TYPE_YML UNIQUE_FIELDS = [FIELD_USERNAME] @@ -110,6 +112,15 @@ class User(model.entity.Entity): setattr(self, k, config[k]) return self + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES + def select_entity(self, job, name, row={}): """ reads the entity from the database diff --git a/model/variant.py b/model/variant.py index 21c36ee..b73888b 100644 --- a/model/variant.py +++ b/model/variant.py @@ -24,6 +24,7 @@ FIELD_COMPONENT = B.SUBJECT_COMP FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_COMPONENT, FIELD_ATTRIBUTES] """ list of object-attributes """ +LIST_NODES = [B.NODE_ATTRIBUTES] LIST_SUBTABLES = [] FILE_EXTENSION = D.DFILE_TYPE_YML @@ -75,5 +76,13 @@ class Variant(model.entity.Entity): :return: """ config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_VARIANTS, tools.config_tool.get_plain_filename(job, name)) - return self.setAttributes(config, name, LIST_FIELDS, LIST_SUBTABLES) + return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES) + def getFieldList(self): + return LIST_FIELDS + + def getNodeList(self): + return LIST_NODES + + def getSubtableList(self): + return LIST_SUBTABLES diff --git a/test/test_14entity.py b/test/test_14entity.py new file mode 100644 index 0000000..4edbabb --- /dev/null +++ b/test/test_14entity.py @@ -0,0 +1,122 @@ +#!/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.testcase +import model.entity +import tools.data_tool + +HOME_PATH = test.constants.HOME_PATH +PYTHON_CMD = "python" +TEST_FUNCTIONS = ["test_10setAttributes"] +TEST_FUNCTIONS = ["test_10setAttributes"] +LIST_XARGS = ["lorem", "ipsum"] +PROGRAM_NAME = "clean_workspace" + +class MyTestCase(unittest.TestCase): + mymsg = "--------------------------------------------------------------" + + def test_10setAttributes(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() + tcname = "TC0001" + tcproject = "TESTPROJ" + testcase = model.testcase.Testcase(job, tcproject) + # eigene Attribute vollstaendig + testcase = model.testcase.Testcase(job, tcproject) + + args = {} + args[tcname] = {} + for k in model.testcase.LIST_FIELDS: + args[tcname][k] = "ATTR_" + k + testcase = testcase.setAttributes(job, args, tcname, + model.testcase.LIST_FIELDS, + model.testcase.LIST_NODES, + model.testcase.LIST_SUBTABLES) + for k in model.testcase.LIST_FIELDS: + if k == model.testcase.FIELD_NAME: + self.assertEqual(tcname, getattr(testcase, k)) + elif k == model.testcase.FIELD_PROJECT: + self.assertEqual(tcproject, getattr(testcase, k)) + else: + self.assertEqual(getattr(testcase, k), "ATTR_" + k) + for k in LIST_XARGS: + self.assertEqual(hasattr(testcase, k), False) + self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), False) + # andere Attribute vollstaendig + testcase = model.testcase.Testcase(job, tcproject) + args = {} + args[tcname] = {} + attr = {} + for k in LIST_XARGS: + args[tcname][k] = "ATTR_" + k + attr[k] = "ATTR_" + k + args[tcname][B.NODE_ATTRIBUTES] = attr + topics = {} + for k in B.LIST_TOPIC_NODES: + topics[k] = {} + topics[k]["type"] = "x-type" + args[tcname][tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)] = topics + testcase = testcase.setAttributes(job, args, tcname, + model.testcase.LIST_FIELDS, + model.testcase.LIST_NODES, + model.testcase.LIST_SUBTABLES) + for k in model.testcase.LIST_FIELDS: + if k == model.testcase.FIELD_NAME: + self.assertEqual(tcname, getattr(testcase, k)) + elif k == model.testcase.FIELD_PROJECT: + self.assertEqual(tcproject, getattr(testcase, k)) + else: + self.assertEqual("", getattr(testcase, k)) + for k in LIST_XARGS: + self.assertEqual(hasattr(testcase, k), False) + for k in model.testcase.LIST_NODES: + self.assertEqual(hasattr(testcase, k), True) + self.assertEqual(hasattr(testcase, tools.data_tool.getPluralKeyword(B.DATA_NODE_TOPICS)), True) + for k in B.LIST_TOPIC_NODES: + self.assertEqual(hasattr(testcase, k), False) + self.assertIn(k ,testcase.topics) + + 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() + testcase = model.testcase.Testcase(job, "TESTPROJ") + entityNames = [] + entityNames = testcase.get_entities(job, storage=model.entity.STORAGE_FILE) + self.assertEqual(type(entityNames), list) + #entityNames = testcase.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() + testcase = model.testcase.Testcase(job, "TESTPROJ") + name = "TC0001" + acttestcase = testcase.read_entity(job, name) + self.assertEqual(getattr(acttestcase, model.testcase.FIELD_NAME), name) + self.assertRaises(Exception, testcase.read_entity, job, "xyzxyz") + +if __name__ == '__main__': + unittest.main() diff --git a/tools/data_const.py b/tools/data_const.py index 5449e88..750863a 100644 --- a/tools/data_const.py +++ b/tools/data_const.py @@ -19,6 +19,7 @@ TYPE_PK = "pk" TYPE_AUTOINT = "autoint" FIELD_NAME = "name" +FIELD_PROJECT = "project" # fields in DDL # _field;comment;format;acceptance;generate;nullable diff --git a/tools/data_tool.py b/tools/data_tool.py index 08a1c5d..23b2e96 100644 --- a/tools/data_tool.py +++ b/tools/data_tool.py @@ -33,6 +33,25 @@ def getPluralAttribut(inkey): def getSingularAttribut(inkey): return "_"+getPurKeyword(inkey) +def getExistKeyword(inkey, inDict): + """ + returns the existing keyword in the dictionary + :param inkey: keyword in any form (singular/plural, as attribute or not) + :param inDict: the existing dictionary + :return: + """ + if inkey in inDict: + return inkey + if getSingularKeyword(inkey) in inDict: + return getSingularKeyword(inkey) + if getPluralKeyword(inkey) in inDict: + return getPluralKeyword(inkey) + if getSingularAttribut(inkey) in inDict: + return getSingularAttribut(inkey) + if getPluralAttribut(inkey) in inDict: + return getPluralAttribut(inkey) + return "" + def isStrDict(invalue): if isinstance(invalue, dict): return True diff --git a/tools/filecsv_fcts.py b/tools/filecsv_fcts.py index b78e753..ab9d95b 100644 --- a/tools/filecsv_fcts.py +++ b/tools/filecsv_fcts.py @@ -101,7 +101,7 @@ class FileFcts(tools.file_abstract.FileFcts): g) data-table: array: field - values # spec.data, comp.artifacts :return: """ - verify = True + verify = False tdata = {} status = "start" verbose = False