-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget_pipeline_parms.py
57 lines (46 loc) · 2.1 KB
/
get_pipeline_parms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from testgen.common.database.database_service import RetrieveDBResultsToDictList
from testgen.common.read_file import read_template_sql_file
def RetrieveProfilingParms(strTableGroupsID):
strSQL = read_template_sql_file("parms_profiling.sql", "parms")
# Replace Parameters
strSQL = strSQL.replace("{TABLE_GROUPS_ID}", strTableGroupsID)
# Execute Query
lstParms = RetrieveDBResultsToDictList("DKTG", strSQL)
if lstParms is None:
raise ValueError("Project Connection Parameters not found")
elif (
lstParms[0]["project_code"] == ""
or lstParms[0]["connection_id"] == ""
or lstParms[0]["sql_flavor"] == ""
or lstParms[0]["project_user"] == ""
or lstParms[0]["profile_use_sampling"] == ""
or lstParms[0]["profile_sample_percent"] == ""
or lstParms[0]["profile_sample_min_count"] == ""
or lstParms[0]["project_qc_schema"] == ""
or lstParms[0]["table_group_schema"] == ""
):
raise ValueError("Project Connection parameters not correctly set")
else:
return lstParms[0]
def RetrieveTestGenParms(strTableGroupsID, strTestSuite):
strSQL = read_template_sql_file("parms_test_gen.sql", "parms")
# Replace Parameters
strSQL = strSQL.replace("{TABLE_GROUPS_ID}", strTableGroupsID)
strSQL = strSQL.replace("{TEST_SUITE}", strTestSuite)
# Execute Query
lstParms = RetrieveDBResultsToDictList("DKTG", strSQL)
if len(lstParms) == 0:
raise ValueError("SQL retrieved 0 records")
return lstParms[0]
def RetrieveTestExecParms(strProjectCode, strTestSuite):
strSQL = read_template_sql_file("parms_test_execution.sql", "parms")
# Replace Parameters
strSQL = strSQL.replace("{PROJECT_CODE}", strProjectCode)
strSQL = strSQL.replace("{TEST_SUITE}", strTestSuite)
# Execute Query
lstParms = RetrieveDBResultsToDictList("DKTG", strSQL)
if len(lstParms) == 0:
raise ValueError("Test Execution parameters could not be retrieved")
elif len(lstParms) > 1:
raise ValueError("Test Execution parameters returned too many records")
return lstParms[0]