Browse Source

bugfixe of searches

refactor
Ulrich 2 years ago
parent
commit
a1a164c2b0
  1. 2
      basic/message.py
  2. 2
      basic/toolHandling.py
  3. 14
      model/application.py
  4. 20
      model/component.py
  5. 0
      model/constants.py
  6. 4
      model/entity.py
  7. 22
      model/factory.py
  8. 57
      test/test_10job.py
  9. 2
      test/test_20application.py
  10. 2
      tools/config_tool.py
  11. 4
      tools/git_tool.py

2
basic/message.py

@ -218,6 +218,8 @@ class Message:
""" """
out = 0 out = 0
job = self.job job = self.job
if not hasattr(job, "par"):
return out
if comp is not None and hasattr(job.par, "component") and comp.name in getattr(job.par, "component"): if comp is not None and hasattr(job.par, "component") and comp.name in getattr(job.par, "component"):
out += 2 out += 2
if tool != "" and hasattr(job.par, "tool") and tool in getattr(job.par, "tool"): if tool != "" and hasattr(job.par, "tool") and tool in getattr(job.par, "tool"):

2
basic/toolHandling.py

@ -6,7 +6,7 @@
# --------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------
import importlib import importlib
import os import os
import basic.program # import basic.program
import basic.constants as B import basic.constants as B
# ------------------------------------------------- # -------------------------------------------------
import tools.config_tool import tools.config_tool

14
model/application.py

@ -2,10 +2,13 @@
# Author : Ulrich Carmesin # Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de # Source : gitea.ucarmesin.de
# --------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------
print("is importing module.app")
import os import os
import basic.toolHandling import basic.toolHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import model.constants as M
import tools.data_const as D import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import tools.config_tool import tools.config_tool
@ -13,9 +16,9 @@ import tools.file_tool
import tools.git_tool import tools.git_tool
TABLE_NAMES = ["application", "ap_project", "ap_component"] TABLE_NAMES = ["application", "ap_project", "ap_component"]
STORAGES = [model.entity.STORAGE_FILE, model.entity.STORAGE_DB] STORAGES = [ M.STORAGE_FILE, M.STORAGE_DB ]
""" used storage in priority sortage, so: if file then read_fcts / if db then select-fcts """ """ used storage in priority sortage, so: if file then read_fcts / if db then select-fcts """
DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB DEFAULT_SYNC = M.SYNC_FULL_GIT2DB
TABLE_NAME = B.SUBJECT_APP TABLE_NAME = B.SUBJECT_APP
""" system-name for this entity """ """ system-name for this entity """
@ -38,6 +41,7 @@ UNIQUE_FIELDS = [FIELD_NAME]
""" unique business field as human identifer """ """ unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID] IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """ """ unique technical field as technical identifer """
print("has imported module.app")
def getProjects(job): def getProjects(job):
""" """
@ -129,6 +133,7 @@ def searchApplications(job, projectList, appl):
def syncEnitity(job, elem): def syncEnitity(job, elem):
return syncEnitities(job) return syncEnitities(job)
import model.entity
def syncEnitities(job): def syncEnitities(job):
""" """
synchronize the configuration with the database synchronize the configuration with the database
@ -225,6 +230,8 @@ def insertEntities(job,applData, dbTime, dbi):
ao.read_entity(job, app) ao.read_entity(job, app)
ao.insertEntity(dbi) ao.insertEntity(dbi)
class Application(model.entity.Entity): class Application(model.entity.Entity):
table = "application" table = "application"
name = "" name = ""
@ -233,6 +240,9 @@ class Application(model.entity.Entity):
components = {} components = {}
project = {} project = {}
def __int__(self, job):
self.job = job
def read_unique_names(self, job, project, application, gran, args): def read_unique_names(self, job, project, application, gran, args):
""" """
reads the entity-names from file-storage reads the entity-names from file-storage

20
model/component.py

@ -6,8 +6,7 @@ import os
import basic.toolHandling import basic.toolHandling
import basic.constants as B import basic.constants as B
import model.entity import model.entity
import model.application import model.factory
# from model.Entity import Entity
import tools.data_const as D import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import tools.config_tool as config_tool import tools.config_tool as config_tool
@ -21,12 +20,12 @@ TABLE_NAME = "component"
""" system-name for this entity """ """ system-name for this entity """
FIELD_ID = "coid" FIELD_ID = "coid"
FIELD_NAME = D.FIELD_NAME FIELD_NAME = D.FIELD_NAME
FIELD_DISCRIPTION = B.SUBJECT_DESCRIPTION FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
FIELD_PROJECT = B.SUBJECT_PROJECT FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_APPLICATION = B.SUBJECT_APP FIELD_APPLICATION = B.SUBJECT_APP
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DISCRIPTION, FIELD_REFERENCE] LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """ """ list of object-attributes """
CP_SUBJECT_COMPS = "components" CP_SUBJECT_COMPS = "components"
@ -88,21 +87,12 @@ class Component(model.entity.Entity):
:param opt. args additional args :param opt. args additional args
:return: list of entity-names :return: list of entity-names
""" """
outList = []
# suche weiterleiten # suche weiterleiten
if application != "": if application != "":
app = model.application.Application() app = model.factory.getApplication()
return list(app.components.keys()) return list(app.components.keys())
path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS]) path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS])
for k in os.listdir(path): outList = self.getDirlist(job, path, "csv")
if k[:1] in [".", "_"]:
continue
if k in [P.KEY_CATALOG, P.KEY_TOOL, P.VAL_CONFIG, P.VAL_TEST, P.VAL_TOOLS]:
continue
if not os.path.isdir(os.path.join(path, k)):
continue
outList.append(k)
return outList return outList
def read_entity(self, job, name): def read_entity(self, job, name):

0
model/constants.py

4
model/entity.py

@ -2,7 +2,7 @@ import getpass
import os import os
import re import re
import basic.toolHandling import basic.toolHandling
import model.entity # import model.entity
import tools.data_const as D import tools.data_const as D
import tools.path_const as P import tools.path_const as P
import basic.constants as B import basic.constants as B
@ -34,7 +34,7 @@ STORAGE_FILE = B.TOPIC_NODE_FILE
LIST_ENTITY_SYNC = [SYNC_ONLY_GIT, SYNC_FULL_GIT2DB, SYNC_HEAD_GIT2DB, SYNC_COPY_FILE2DB, SYNC_ONLY_DB] LIST_ENTITY_SYNC = [SYNC_ONLY_GIT, SYNC_FULL_GIT2DB, SYNC_HEAD_GIT2DB, SYNC_COPY_FILE2DB, SYNC_ONLY_DB]
print("is importing module.entity")
def getEntityValue(job, field, gitcommit): def getEntityValue(job, field, gitcommit):
if field == ENTITY_INS_COMMIT: if field == ENTITY_INS_COMMIT:
return "" return ""

22
model/factory.py

@ -0,0 +1,22 @@
import model.entity
def getEnvironment(job=None):
import model.environment
return model.environment.Environment(job)
def getApplication(job=None):
import model.application
return model.application.Application()
def getComponent(job=None):
import model.component
return model.component.Component(job)
def getTestsuite(job=None, project="", application=""):
import model.testsuite
return model.testsuite.Testsuite(job, project)
def getTestcase(job=None, project="", application=""):
import model.testcase
return model.testcase.Testcase(job, project)

57
test/test_10job.py

@ -2,7 +2,18 @@ import unittest
import os import os
import inspect import inspect
import shutil import shutil
print("start import 1")
#import model.entity
print("start import 2")
#import model.environment
print("start import 3")
#import model.application
print("start import 4")
#import model.component
print("start import 5")
import model.testcase
import model.testsuite
import model.factory
import tools.path_tool import tools.path_tool
import tools.job_tool import tools.job_tool
import basic.program import basic.program
@ -15,8 +26,10 @@ import tools.file_tool
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_00init", "test_30startActJob"] TEST_FUNCTIONS = ["test_00init",
TEST_FUNCTIONS = ["test_00init"] "test_11selectApplication", "test_12selectComponent", "test_13selectEnvironment"
"test_30startActJob"]
TEST_FUNCTIONS = ["test_11selectApplication", "test_12selectComponent", "test_13selectEnvironment"]
PROGRAM_NAME = "clean_workspace" PROGRAM_NAME = "clean_workspace"
@ -46,6 +59,18 @@ class MyTestCase(unittest.TestCase):
self.assertIn("configpath", job.conf) self.assertIn("configpath", job.conf)
self.assertIn("paths", job.conf) self.assertIn("paths", job.conf)
def test_11selectApplication(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
# simple job instantiate - without parameter and only simple messaging
job = basic.program.Job(PROGRAM_NAME)
res = tools.job_tool.select_application(job, {}, "TESTPROJ")
self.assertIsInstance(res, list)
print(str(res))
def test_30startActJob(self): def test_30startActJob(self):
global mymsg global mymsg
actfunction = str(inspect.currentframe().f_code.co_name) actfunction = str(inspect.currentframe().f_code.co_name)
@ -58,5 +83,31 @@ class MyTestCase(unittest.TestCase):
args = tools.file_tool.read_file_dict(job, path, job.m) args = tools.file_tool.read_file_dict(job, path, job.m)
tools.job_tool.start_child_process(job, args) tools.job_tool.start_child_process(job, args)
def test_12selectComponent(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
# simple job instantiate - without parameter and only simple messaging
job = basic.program.Job(PROGRAM_NAME)
# res = tools.job_tool.select_components(job, {}, "TESTPROJ", "")
res = model.factory.getComponent(job).read_unique_names(job, "TESTPROJ", "", "", {})
self.assertIsInstance(res, list)
print(str(res))
def test_13selectEnvironment(self):
global mymsg
actfunction = str(inspect.currentframe().f_code.co_name)
cnttest = 0
if actfunction not in TEST_FUNCTIONS:
return
# simple job instantiate - without parameter and only simple messaging
job = basic.program.Job(PROGRAM_NAME)
#res = tools.job_tool.select_components(job, {}, "TESTPROJ", "")
res = model.environment.Environment(job).read_unique_names(job, "TESTPROJ", "", "", {})
self.assertIsInstance(res, list)
print(str(res))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

2
test/test_20application.py

@ -14,7 +14,7 @@ import model.application
HOME_PATH = test.constants.HOME_PATH HOME_PATH = test.constants.HOME_PATH
PYTHON_CMD = "python" PYTHON_CMD = "python"
TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_10getApplications"] TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity", "test_10getApplications"]
TEST_FUNCTIONS = ["test_12getEntity"] #TEST_FUNCTIONS = ["test_12getEntity"]
PROGRAM_NAME = "clean_workspace" PROGRAM_NAME = "clean_workspace"

2
tools/config_tool.py

@ -11,7 +11,7 @@ import basic.constants as B
try: try:
import basic.program import basic.program
except ImportError: except ImportError:
print("ImportError: " + str(ImportError.with_traceback())) print("ImportError: " + str(ImportError))
pass pass
import basic.componentHandling import basic.componentHandling
import tools.path_tool import tools.path_tool

4
tools/git_tool.py

@ -9,10 +9,10 @@ import re
import subprocess import subprocess
import sys import sys
import basic.toolHandling import basic.toolHandling
import utils.data_const as D import tools.data_const as D
import basic.constants as B import basic.constants as B
import basic.text_const as T import basic.text_const as T
import utils.date_tool import tools.date_tool
DEFAULT_CNT_COMMITS = 10 DEFAULT_CNT_COMMITS = 10
COMMIT_ID = "commit" COMMIT_ID = "commit"

Loading…
Cancel
Save