Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.5 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
import os
import basic.program
import basic.constants as B
import utils.path_const as P
import utils.data_const as D
import utils.path_tool
import utils.tdata_tool
EXP_KEY_MISSING = "key is missing {}"
EXP_KEY_DOESNT_EXIST = "key doesnt exist in domain {}"
class Catalog:
__instance = None
"""
in this class there should be managed each defined key-value-pairs
the pairs ara loaded from the path testdata/catalog:
* initially the csv-file catalog.csv
* on demand other csv-files in the path
"""
def __init__(self):
self.catalog = {}
Catalog.__instance = self
pass
@staticmethod
def getInstance():
if Catalog.__instance == None:
return Catalog()
return Catalog.__instance
def getValue(self, domain, key):
"""
this function gets the value of the domain an key
:param domain:
:param key:
:return:
"""
job = basic.program.Job.getInstance()
if not (isinstance(domain, str) and len(domain)):
raise Exception(EXP_KEY_MISSING, (domain, key))
if not (isinstance(key, str) and len(key)):
raise Exception(EXP_KEY_MISSING, (domain, key))
if domain not in self.catalog:
self.readDomain(domain)
if key not in self.catalog[domain][key]:
raise Exception(EXP_KEY_DOESNT_EXIST, (domain, key))
return self.catalog[domain][key]
def readDomain(self, domain):
"""
this function reads the domain-entries
:param domain:
:return:
"""
job = basic.program.Job.getInstance()
if not (isinstance(domain, str) and len(domain)):
raise Exception(EXP_KEY_MISSING, (domain))
if domain in self.catalog:
return
filename = utils.path_tool.rejoinPath(job.conf.getPath(P.ATTR_PATH_TDATA), "catalog", domain+".csv")
data = utils.tdata_tool.getCsvSpec(job.m, filename, D.CSV_SPECTYPE_KEYS)
self.catalog[domain] = data[B.DATA_NODE_TABLES][domain][B.DATA_NODE_KEYS]
def exportXSD(self, domain):
"""
this function exports the domain into xsd-declaration of simple types
:return:
"""
pass