dataops-testgen 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dataops_testgen-2.2.0.dist-info/LICENSE +203 -0
- dataops_testgen-2.2.0.dist-info/METADATA +287 -0
- dataops_testgen-2.2.0.dist-info/NOTICE +5 -0
- dataops_testgen-2.2.0.dist-info/RECORD +270 -0
- dataops_testgen-2.2.0.dist-info/WHEEL +5 -0
- dataops_testgen-2.2.0.dist-info/entry_points.txt +2 -0
- dataops_testgen-2.2.0.dist-info/top_level.txt +1 -0
- testgen/__init__.py +0 -0
- testgen/__main__.py +770 -0
- testgen/commands/__init__.py +0 -0
- testgen/commands/queries/__init__.py +0 -0
- testgen/commands/queries/execute_cat_tests_query.py +95 -0
- testgen/commands/queries/execute_tests_query.py +160 -0
- testgen/commands/queries/generate_tests_query.py +94 -0
- testgen/commands/queries/profiling_query.py +366 -0
- testgen/commands/queries/test_parameter_validation_query.py +88 -0
- testgen/commands/run_execute_cat_tests.py +162 -0
- testgen/commands/run_execute_tests.py +168 -0
- testgen/commands/run_generate_tests.py +107 -0
- testgen/commands/run_get_entities.py +122 -0
- testgen/commands/run_launch_db_config.py +84 -0
- testgen/commands/run_observability_exporter.py +330 -0
- testgen/commands/run_profiling_bridge.py +495 -0
- testgen/commands/run_quick_start.py +168 -0
- testgen/commands/run_setup_profiling_tools.py +96 -0
- testgen/commands/run_test_definition.py +146 -0
- testgen/commands/run_test_parameter_validation.py +135 -0
- testgen/commands/run_upgrade_db_config.py +156 -0
- testgen/common/__init__.py +8 -0
- testgen/common/clean_sql.py +53 -0
- testgen/common/credentials.py +25 -0
- testgen/common/database/__init__.py +0 -0
- testgen/common/database/database_service.py +629 -0
- testgen/common/database/flavor/__init__.py +0 -0
- testgen/common/database/flavor/flavor_service.py +75 -0
- testgen/common/database/flavor/mssql_flavor_service.py +34 -0
- testgen/common/database/flavor/postgresql_flavor_service.py +5 -0
- testgen/common/database/flavor/redshift_flavor_service.py +22 -0
- testgen/common/database/flavor/snowflake_flavor_service.py +69 -0
- testgen/common/database/flavor/trino_flavor_service.py +21 -0
- testgen/common/date_service.py +68 -0
- testgen/common/display_service.py +85 -0
- testgen/common/docker_service.py +76 -0
- testgen/common/encrypt.py +55 -0
- testgen/common/get_pipeline_parms.py +57 -0
- testgen/common/logs.py +79 -0
- testgen/common/process_service.py +62 -0
- testgen/common/read_file.py +69 -0
- testgen/settings.py +440 -0
- testgen/template/dbsetup/010_create_base_schema.sql +2 -0
- testgen/template/dbsetup/020_create_standard_functions_sprocs.sql +179 -0
- testgen/template/dbsetup/030_initialize_new_schema_structure.sql +735 -0
- testgen/template/dbsetup/040_populate_new_schema_project.sql +59 -0
- testgen/template/dbsetup/050_populate_new_schema_metadata.sql +1517 -0
- testgen/template/dbsetup/060_create_standard_views.sql +248 -0
- testgen/template/dbsetup/070_create_default_users.sql +17 -0
- testgen/template/dbsetup/075_grant_role_rights.sql +43 -0
- testgen/template/dbsetup/080_set_current_revision.sql +5 -0
- testgen/template/dbupgrade/0100_incremental_upgrade.sql +5 -0
- testgen/template/dbupgrade/0101_incremental_upgrade.sql +15 -0
- testgen/template/dbupgrade/0102_incremental_upgrade.sql +4 -0
- testgen/template/dbupgrade/0103_incremental_upgrade.sql +22 -0
- testgen/template/dbupgrade/0104_incremental_upgrade.sql +44 -0
- testgen/template/dbupgrade/0105_incremental_upgrade.sql +1 -0
- testgen/template/dbupgrade/0106_incremental_upgrade.sql +5 -0
- testgen/template/dbupgrade/0107_incremental_upgrade.sql +3 -0
- testgen/template/dbupgrade_helpers/get_tg_revision.sql +2 -0
- testgen/template/exec_cat_tests/ex_cat_build_agg_table_tests.sql +116 -0
- testgen/template/exec_cat_tests/ex_cat_get_distinct_tables.sql +11 -0
- testgen/template/exec_cat_tests/ex_cat_results_parse.sql +69 -0
- testgen/template/exec_cat_tests/ex_cat_retrieve_agg_test_parms.sql +6 -0
- testgen/template/exec_cat_tests/ex_cat_test_query.sql +8 -0
- testgen/template/execution/ex_finalize_test_run_results.sql +37 -0
- testgen/template/execution/ex_get_tests_non_cat.sql +47 -0
- testgen/template/execution/ex_update_test_record_in_testrun_table.sql +27 -0
- testgen/template/execution/ex_write_test_record_to_testrun_table.sql +6 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_no_drops_generic.sql +48 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_num_incr_generic.sql +34 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_above_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_within_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_same_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_custom_query_generic.sql +39 -0
- testgen/template/flavors/generic/exec_query_tests/ex_data_match_2way_generic.sql +58 -0
- testgen/template/flavors/generic/exec_query_tests/ex_data_match_generic.sql +44 -0
- testgen/template/flavors/generic/exec_query_tests/ex_prior_match_generic.sql +37 -0
- testgen/template/flavors/generic/exec_query_tests/ex_relative_entropy_generic.sql +53 -0
- testgen/template/flavors/generic/exec_query_tests/ex_window_match_no_drops_generic.sql +46 -0
- testgen/template/flavors/generic/exec_query_tests/ex_window_match_same_generic.sql +59 -0
- testgen/template/flavors/generic/profiling/contingency_counts.sql +3 -0
- testgen/template/flavors/generic/validate_tests/ex_get_project_column_list_generic.sql +3 -0
- testgen/template/flavors/mssql/exec_query_tests/ex_relative_entropy_mssql.sql +53 -0
- testgen/template/flavors/mssql/profiling/project_ddf_query_mssql.sql +35 -0
- testgen/template/flavors/mssql/profiling/project_profiling_query_mssql.yaml +246 -0
- testgen/template/flavors/mssql/profiling/project_secondary_profiling_query_mssql.sql +36 -0
- testgen/template/flavors/mssql/setup_profiling_tools/00_drop_existing_functions_mssql.sql +8 -0
- testgen/template/flavors/mssql/setup_profiling_tools/01_create_functions_mssql.sql +12 -0
- testgen/template/flavors/mssql/setup_profiling_tools/02_create_functions_mssql.sql +54 -0
- testgen/template/flavors/mssql/setup_profiling_tools/create_qc_schema_mssql.sql +4 -0
- testgen/template/flavors/mssql/setup_profiling_tools/grant_execute_privileges_mssql.sql +1 -0
- testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_no_drops_postgresql.sql +46 -0
- testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_same_postgresql.sql +59 -0
- testgen/template/flavors/postgresql/profiling/project_ddf_query_postgresql.sql +42 -0
- testgen/template/flavors/postgresql/profiling/project_profiling_query_postgresql.yaml +225 -0
- testgen/template/flavors/postgresql/profiling/project_secondary_profiling_query_postgresql.sql +28 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/create_functions_postgresql.sql +157 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/create_qc_schema_postgresql.sql +1 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/grant_execute_privileges_postgresql.sql +2 -0
- testgen/template/flavors/redshift/profiling/project_ddf_query_redshift.sql +38 -0
- testgen/template/flavors/redshift/profiling/project_profiling_query_redshift.yaml +221 -0
- testgen/template/flavors/redshift/profiling/project_secondary_profiling_query_redshift.sql +29 -0
- testgen/template/flavors/redshift/setup_profiling_tools/create_functions_redshift.sql +115 -0
- testgen/template/flavors/redshift/setup_profiling_tools/create_qc_schema_redshift.sql +1 -0
- testgen/template/flavors/redshift/setup_profiling_tools/grant_execute_privileges_redshift.sql +2 -0
- testgen/template/flavors/snowflake/profiling/project_ddf_query_snowflake.sql +38 -0
- testgen/template/flavors/snowflake/profiling/project_profiling_query_snowflake.yaml +220 -0
- testgen/template/flavors/snowflake/profiling/project_secondary_profiling_query_snowflake.sql +29 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/create_functions_snowflake.sql +69 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/create_qc_schema_snowflake.sql +1 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/grant_execute_privileges_snowflake.sql +6 -0
- testgen/template/flavors/trino/profiling/project_profiling_query_trino.yaml +219 -0
- testgen/template/flavors/trino/setup_profiling_tools/create_functions_trino.sql +92 -0
- testgen/template/flavors/trino/setup_profiling_tools/create_qc_schema_trino.sql +1 -0
- testgen/template/gen_funny_cat_tests/gen_test_constant.sql +104 -0
- testgen/template/gen_funny_cat_tests/gen_test_distinct_value_ct.sql +98 -0
- testgen/template/gen_funny_cat_tests/gen_test_row_ct.sql +57 -0
- testgen/template/gen_funny_cat_tests/gen_test_row_ct_pct.sql +59 -0
- testgen/template/generation/gen_delete_old_tests.sql +5 -0
- testgen/template/generation/gen_insert_test_suite.sql +5 -0
- testgen/template/generation/gen_retrieve_or_insert_test_suite.sql +58 -0
- testgen/template/generation/gen_standard_test_type_list.sql +13 -0
- testgen/template/generation/gen_standard_tests.sql +48 -0
- testgen/template/get_entities/get_connection.sql +21 -0
- testgen/template/get_entities/get_connections_list.sql +9 -0
- testgen/template/get_entities/get_latest.sql +4 -0
- testgen/template/get_entities/get_profile.sql +12 -0
- testgen/template/get_entities/get_profile_info.sql +17 -0
- testgen/template/get_entities/get_profile_list.sql +17 -0
- testgen/template/get_entities/get_profile_screen.sql +275 -0
- testgen/template/get_entities/get_project_list.sql +6 -0
- testgen/template/get_entities/get_table_group_list.sql +10 -0
- testgen/template/get_entities/get_test_generation_list.sql +18 -0
- testgen/template/get_entities/get_test_info.sql +41 -0
- testgen/template/get_entities/get_test_results_for_run_cli.sql +16 -0
- testgen/template/get_entities/get_test_run_list.sql +24 -0
- testgen/template/get_entities/get_test_suite.sql +13 -0
- testgen/template/get_entities/get_test_suite_list.sql +18 -0
- testgen/template/get_entities/list_test_types.sql +4 -0
- testgen/template/observability/get_event_data.sql +23 -0
- testgen/template/observability/get_test_results.sql +41 -0
- testgen/template/observability/update_test_results_exported_to_observability.sql +12 -0
- testgen/template/parms/parms_profiling.sql +34 -0
- testgen/template/parms/parms_test_execution.sql +13 -0
- testgen/template/parms/parms_test_gen.sql +23 -0
- testgen/template/profiling/contingency_columns.sql +7 -0
- testgen/template/profiling/datatype_suggestions.sql +56 -0
- testgen/template/profiling/functional_datatype.sql +523 -0
- testgen/template/profiling/functional_tabletype_stage.sql +48 -0
- testgen/template/profiling/functional_tabletype_update.sql +8 -0
- testgen/template/profiling/pii_flag.sql +133 -0
- testgen/template/profiling/profile_anomalies_screen_column.sql +22 -0
- testgen/template/profiling/profile_anomalies_screen_multi_column.sql +58 -0
- testgen/template/profiling/profile_anomalies_screen_table.sql +22 -0
- testgen/template/profiling/profile_anomalies_screen_table_dates.sql +30 -0
- testgen/template/profiling/profile_anomalies_screen_variants.sql +40 -0
- testgen/template/profiling/profile_anomaly_types_get.sql +3 -0
- testgen/template/profiling/project_get_table_sample_count.sql +22 -0
- testgen/template/profiling/project_profile_run_record_insert.sql +8 -0
- testgen/template/profiling/project_profile_run_record_update.sql +5 -0
- testgen/template/profiling/project_profile_run_record_update_status.sql +5 -0
- testgen/template/profiling/project_update_profile_results_to_estimates.sql +32 -0
- testgen/template/profiling/refresh_anomalies.sql +33 -0
- testgen/template/profiling/refresh_data_chars_from_profiling.sql +156 -0
- testgen/template/profiling/secondary_profiling_columns.sql +12 -0
- testgen/template/profiling/secondary_profiling_delete.sql +4 -0
- testgen/template/profiling/secondary_profiling_update.sql +18 -0
- testgen/template/quick_start/populate_target_data.sql +1077 -0
- testgen/template/quick_start/recreate_target_data_schema.sql +167 -0
- testgen/template/quick_start/update_target_data.sql +100 -0
- testgen/template/updates/create_tmp_test_definition.sql +19 -0
- testgen/template/updates/get_test_def_parms.sql +38 -0
- testgen/template/updates/populate_stg_test_definitions.sql +184 -0
- testgen/template/validate_tests/ex_disable_tests_test_definitions.sql +5 -0
- testgen/template/validate_tests/ex_flag_tests_test_definitions.sql +64 -0
- testgen/template/validate_tests/ex_get_project_column_list_generic.sql +3 -0
- testgen/template/validate_tests/ex_get_test_column_list_tg.sql +65 -0
- testgen/template/validate_tests/ex_write_test_val_errors.sql +22 -0
- testgen/ui/__init__.py +0 -0
- testgen/ui/app.py +98 -0
- testgen/ui/assets/dk_logo.svg +46 -0
- testgen/ui/assets/question_mark.png +0 -0
- testgen/ui/assets/scripts.js +68 -0
- testgen/ui/assets/style.css +140 -0
- testgen/ui/bootstrap.py +109 -0
- testgen/ui/components/__init__.py +0 -0
- testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu4mxK.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 +0 -0
- testgen/ui/components/frontend/css/material-symbols-rounded.css +24 -0
- testgen/ui/components/frontend/css/material-symbols-rounded.woff2 +0 -0
- testgen/ui/components/frontend/css/roboto-font-faces.css +35 -0
- testgen/ui/components/frontend/css/shared.css +36 -0
- testgen/ui/components/frontend/img/dk_logo.svg +46 -0
- testgen/ui/components/frontend/index.html +17 -0
- testgen/ui/components/frontend/js/components/breadcrumbs.js +86 -0
- testgen/ui/components/frontend/js/components/button.js +66 -0
- testgen/ui/components/frontend/js/components/location.js +62 -0
- testgen/ui/components/frontend/js/components/select.js +75 -0
- testgen/ui/components/frontend/js/components/sidebar.js +358 -0
- testgen/ui/components/frontend/js/main.js +99 -0
- testgen/ui/components/frontend/js/streamlit.js +19 -0
- testgen/ui/components/frontend/js/van.min.js +1 -0
- testgen/ui/components/utils/__init__.py +0 -0
- testgen/ui/components/utils/callbacks.py +51 -0
- testgen/ui/components/utils/component.py +13 -0
- testgen/ui/components/widgets/__init__.py +6 -0
- testgen/ui/components/widgets/breadcrumbs.py +32 -0
- testgen/ui/components/widgets/location.py +65 -0
- testgen/ui/components/widgets/modal.py +97 -0
- testgen/ui/components/widgets/sidebar.py +69 -0
- testgen/ui/navigation/__init__.py +0 -0
- testgen/ui/navigation/menu.py +42 -0
- testgen/ui/navigation/page.py +20 -0
- testgen/ui/navigation/router.py +63 -0
- testgen/ui/queries/__init__.py +0 -0
- testgen/ui/queries/authentication_queries.py +47 -0
- testgen/ui/queries/connection_queries.py +121 -0
- testgen/ui/queries/profiling_queries.py +148 -0
- testgen/ui/queries/project_queries.py +9 -0
- testgen/ui/queries/table_group_queries.py +186 -0
- testgen/ui/queries/test_definition_queries.py +270 -0
- testgen/ui/queries/test_run_queries.py +32 -0
- testgen/ui/queries/test_suite_queries.py +145 -0
- testgen/ui/scripts/__init__.py +0 -0
- testgen/ui/scripts/patch_streamlit.py +111 -0
- testgen/ui/services/__init__.py +0 -0
- testgen/ui/services/authentication_service.py +119 -0
- testgen/ui/services/connection_service.py +220 -0
- testgen/ui/services/database_service.py +282 -0
- testgen/ui/services/form_service.py +1008 -0
- testgen/ui/services/javascript_service.py +44 -0
- testgen/ui/services/query_service.py +316 -0
- testgen/ui/services/string_service.py +12 -0
- testgen/ui/services/table_group_service.py +130 -0
- testgen/ui/services/test_definition_service.py +117 -0
- testgen/ui/services/test_run_service.py +13 -0
- testgen/ui/services/test_suite_service.py +76 -0
- testgen/ui/services/toolbar_service.py +77 -0
- testgen/ui/session.py +46 -0
- testgen/ui/views/__init__.py +0 -0
- testgen/ui/views/app_log_modal.py +92 -0
- testgen/ui/views/connections.py +72 -0
- testgen/ui/views/connections_base.py +367 -0
- testgen/ui/views/login.py +40 -0
- testgen/ui/views/not_found.py +16 -0
- testgen/ui/views/overview.py +34 -0
- testgen/ui/views/profiling_anomalies.py +501 -0
- testgen/ui/views/profiling_details.py +335 -0
- testgen/ui/views/profiling_modal.py +40 -0
- testgen/ui/views/profiling_results.py +206 -0
- testgen/ui/views/profiling_summary.py +177 -0
- testgen/ui/views/project_settings.py +74 -0
- testgen/ui/views/table_groups.py +530 -0
- testgen/ui/views/test_definitions.py +1020 -0
- testgen/ui/views/test_results.py +908 -0
- testgen/ui/views/test_runs.py +195 -0
- testgen/ui/views/test_suites.py +545 -0
- testgen/utils/__init__.py +0 -0
- testgen/utils/plugins.py +17 -0
- testgen/utils/singleton.py +14 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from testgen.common import date_service, read_template_sql_file
|
|
4
|
+
from testgen.common.database import database_service
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CCATExecutionSQL:
|
|
8
|
+
project_code = ""
|
|
9
|
+
flavor = ""
|
|
10
|
+
concat_operator = ""
|
|
11
|
+
test_suite = ""
|
|
12
|
+
run_date = ""
|
|
13
|
+
test_run_id = ""
|
|
14
|
+
max_query_chars = ""
|
|
15
|
+
exception_message = ""
|
|
16
|
+
|
|
17
|
+
# Test Set Parameters
|
|
18
|
+
target_schema = ""
|
|
19
|
+
target_table = ""
|
|
20
|
+
replace_qc_schema = ""
|
|
21
|
+
dctTestParms: typing.ClassVar = {}
|
|
22
|
+
|
|
23
|
+
def __init__(self, strProjectCode, strTestSuite, strSQLFlavor, max_query_chars, minutes_offset=0):
|
|
24
|
+
# Defaults
|
|
25
|
+
self.test_suite = strTestSuite
|
|
26
|
+
self.project_code = strProjectCode
|
|
27
|
+
flavor_service = database_service.get_flavor_service(strSQLFlavor)
|
|
28
|
+
self.concat_operator = flavor_service.get_concat_operator()
|
|
29
|
+
self.flavor = strSQLFlavor
|
|
30
|
+
self.max_query_chars = max_query_chars
|
|
31
|
+
self.today = date_service.get_now_as_string_with_offset(minutes_offset)
|
|
32
|
+
self.minutes_offset = minutes_offset
|
|
33
|
+
|
|
34
|
+
def _ReplaceParms(self, strInputString):
|
|
35
|
+
strInputString = strInputString.replace("{MAX_QUERY_CHARS}", str(self.max_query_chars))
|
|
36
|
+
strInputString = strInputString.replace("{TEST_RUN_ID}", self.test_run_id)
|
|
37
|
+
strInputString = strInputString.replace("{PROJECT_CODE}", self.project_code)
|
|
38
|
+
strInputString = strInputString.replace("{TEST_SUITE}", self.test_suite)
|
|
39
|
+
# NOTE: REPLACE_QC_SCHEMA is parm replaced to run build query: sets the actual value to replace.
|
|
40
|
+
# DATA_QC_SCHEMA is parm in cat_test_conditions that build query replaces via SQL.
|
|
41
|
+
strInputString = strInputString.replace("{REPLACE_QC_SCHEMA}", self.replace_qc_schema)
|
|
42
|
+
strInputString = strInputString.replace("{SQL_FLAVOR}", self.flavor)
|
|
43
|
+
strInputString = strInputString.replace("{CONCAT_OPERATOR}", self.concat_operator)
|
|
44
|
+
|
|
45
|
+
strInputString = strInputString.replace("{SCHEMA_NAME}", self.target_schema)
|
|
46
|
+
strInputString = strInputString.replace("{TABLE_NAME}", self.target_table)
|
|
47
|
+
|
|
48
|
+
strInputString = strInputString.replace("{RUN_DATE}", self.run_date)
|
|
49
|
+
strInputString = strInputString.replace("{NOW_DATE}", "GETDATE()")
|
|
50
|
+
strInputString = strInputString.replace("{START_TIME}", self.today)
|
|
51
|
+
strInputString = strInputString.replace(
|
|
52
|
+
"{NOW}", date_service.get_now_as_string_with_offset(self.minutes_offset)
|
|
53
|
+
)
|
|
54
|
+
strInputString = strInputString.replace("{EXCEPTION_MESSAGE}", self.exception_message.strip())
|
|
55
|
+
|
|
56
|
+
for parm, value in self.dctTestParms.items():
|
|
57
|
+
strInputString = strInputString.replace("{" + parm.upper() + "}", str(value))
|
|
58
|
+
|
|
59
|
+
strInputString = strInputString.replace("{RUN_DATE}", self.run_date)
|
|
60
|
+
|
|
61
|
+
# Adding escape character where ':' is referenced
|
|
62
|
+
strInputString = strInputString.replace(":", "\\:")
|
|
63
|
+
|
|
64
|
+
return strInputString
|
|
65
|
+
|
|
66
|
+
def GetDistinctTablesSQL(self):
|
|
67
|
+
# Runs on DK DB
|
|
68
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_cat_get_distinct_tables.sql", "exec_cat_tests"))
|
|
69
|
+
return strQ
|
|
70
|
+
|
|
71
|
+
def GetAggregateTableTestSQL(self):
|
|
72
|
+
# Runs on DK DB
|
|
73
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_cat_build_agg_table_tests.sql", "exec_cat_tests"))
|
|
74
|
+
return strQ
|
|
75
|
+
|
|
76
|
+
def GetAggregateTestParmsSQL(self):
|
|
77
|
+
# Runs on DK DB
|
|
78
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_cat_retrieve_agg_test_parms.sql", "exec_cat_tests"))
|
|
79
|
+
return strQ
|
|
80
|
+
|
|
81
|
+
def PrepCATQuerySQL(self):
|
|
82
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_cat_test_query.sql", "exec_cat_tests"))
|
|
83
|
+
return strQ
|
|
84
|
+
|
|
85
|
+
def GetCATResultsParseSQL(self):
|
|
86
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_cat_results_parse.sql", "exec_cat_tests"))
|
|
87
|
+
return strQ
|
|
88
|
+
|
|
89
|
+
def FinalizeTestResultsSQL(self):
|
|
90
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_finalize_test_run_results.sql", "execution"))
|
|
91
|
+
return strQ
|
|
92
|
+
|
|
93
|
+
def PushTestRunStatusUpdateSQL(self):
|
|
94
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_update_test_record_in_testrun_table.sql", "execution"))
|
|
95
|
+
return strQ
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from testgen.common import AddQuotesToIdentifierCSV, CleanSQL, ConcatColumnList, date_service, read_template_sql_file
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CTestExecutionSQL:
|
|
7
|
+
flavor = ""
|
|
8
|
+
run_date = ""
|
|
9
|
+
project_code = ""
|
|
10
|
+
test_suite = ""
|
|
11
|
+
test_run_id = ""
|
|
12
|
+
exception_message = ""
|
|
13
|
+
process_id = ""
|
|
14
|
+
|
|
15
|
+
# Test Group Parameters
|
|
16
|
+
dctTestParms: typing.ClassVar = {}
|
|
17
|
+
sum_columns = ""
|
|
18
|
+
match_sum_columns = ""
|
|
19
|
+
multi_column_error_condition = ""
|
|
20
|
+
|
|
21
|
+
def __init__(self, strProjectCode, strFlavor, strTestSuite, minutes_offset=0):
|
|
22
|
+
self.project_code = strProjectCode
|
|
23
|
+
self.flavor = strFlavor
|
|
24
|
+
self.test_suite = strTestSuite
|
|
25
|
+
self.today = date_service.get_now_as_string_with_offset(minutes_offset)
|
|
26
|
+
self.minutes_offset = minutes_offset
|
|
27
|
+
|
|
28
|
+
def _AssembleDisplayParameters(self):
|
|
29
|
+
|
|
30
|
+
lst_parms = ["column_name", "skip_errors", "baseline_ct", "baseline_unique_ct", "baseline_value",
|
|
31
|
+
"baseline_value_ct", "baseline_sum", "baseline_avg", "baseline_sd", "subset_condition",
|
|
32
|
+
"groupby_names", "having_condition", "window_date_column", "window_days",
|
|
33
|
+
"match_column_names", "match_subset_condition", "match_schema_name", "match_table_name",
|
|
34
|
+
"match_groupby_names", "match_having_condition",
|
|
35
|
+
]
|
|
36
|
+
str_parms = "; ".join(f"{key}={self.dctTestParms[key]}"
|
|
37
|
+
for key in lst_parms
|
|
38
|
+
if key.lower() in self.dctTestParms and self.dctTestParms[key] not in [None, ""])
|
|
39
|
+
str_parms = str_parms.replace("'", "`")
|
|
40
|
+
return str_parms
|
|
41
|
+
|
|
42
|
+
def _ReplaceParms(self, strInputString: str):
|
|
43
|
+
strInputString = strInputString.replace("{PROJECT_CODE}", self.project_code)
|
|
44
|
+
strInputString = strInputString.replace("{TEST_SUITE}", self.test_suite)
|
|
45
|
+
strInputString = strInputString.replace("{SQL_FLAVOR}", self.flavor)
|
|
46
|
+
strInputString = strInputString.replace("{TEST_RUN_ID}", self.test_run_id)
|
|
47
|
+
strInputString = strInputString.replace("{INPUT_PARAMETERS}", self._AssembleDisplayParameters())
|
|
48
|
+
|
|
49
|
+
strInputString = strInputString.replace("{RUN_DATE}", self.run_date)
|
|
50
|
+
strInputString = strInputString.replace("{EXCEPTION_MESSAGE}", self.exception_message)
|
|
51
|
+
strInputString = strInputString.replace("{START_TIME}", self.today)
|
|
52
|
+
strInputString = strInputString.replace("{PROCESS_ID}", str(self.process_id))
|
|
53
|
+
strInputString = strInputString.replace(
|
|
54
|
+
"{NOW}", date_service.get_now_as_string_with_offset(self.minutes_offset)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
column_designators = [
|
|
58
|
+
"COLUMN_NAME",
|
|
59
|
+
# "COLUMN_NAMES",
|
|
60
|
+
# "COL_NAME",
|
|
61
|
+
# "COL_NAMES",
|
|
62
|
+
# "MATCH_COLUMN_NAMES",
|
|
63
|
+
# "MATCH_GROUPBY_NAMES",
|
|
64
|
+
# "MATCH_SUM_COLUMNS",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
for parm, value in self.dctTestParms.items():
|
|
68
|
+
if value:
|
|
69
|
+
if parm.upper() in column_designators:
|
|
70
|
+
strInputString = strInputString.replace("{" + parm.upper() + "}", AddQuotesToIdentifierCSV(value))
|
|
71
|
+
else:
|
|
72
|
+
strInputString = strInputString.replace("{" + parm.upper() + "}", value)
|
|
73
|
+
else:
|
|
74
|
+
strInputString = strInputString.replace("{" + parm.upper() + "}", "")
|
|
75
|
+
if parm == "column_name":
|
|
76
|
+
# Shows contents without double-quotes for display and aggregate expressions
|
|
77
|
+
strInputString = strInputString.replace("{COLUMN_NAME_NO_QUOTES}", value if value else "")
|
|
78
|
+
# Concatenates column list into single expression for relative entropy
|
|
79
|
+
str_value = ConcatColumnList(value, "<NULL>")
|
|
80
|
+
strInputString = strInputString.replace("{CONCAT_COLUMNS}", str_value if str_value else "")
|
|
81
|
+
if parm == "match_groupby_names":
|
|
82
|
+
# Concatenates column list into single expression for relative entropy
|
|
83
|
+
str_value = ConcatColumnList(value, "<NULL>")
|
|
84
|
+
strInputString = strInputString.replace("{CONCAT_MATCH_GROUPBY}", str_value if str_value else "")
|
|
85
|
+
if parm == "subset_condition":
|
|
86
|
+
strInputString = strInputString.replace("{SUBSET_DISPLAY}", value.replace("'", "''") if value else "")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Adding escape character where ':' is referenced
|
|
90
|
+
strInputString = strInputString.replace(":", "\\:")
|
|
91
|
+
|
|
92
|
+
return strInputString
|
|
93
|
+
|
|
94
|
+
def ClearTestParms(self):
|
|
95
|
+
# Test Set Parameters
|
|
96
|
+
pass
|
|
97
|
+
|
|
98
|
+
def GetTestsNonCAT(self, booClean):
|
|
99
|
+
# Runs on DK DB
|
|
100
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_get_tests_non_cat.sql", "execution"))
|
|
101
|
+
if booClean:
|
|
102
|
+
strQ = CleanSQL(strQ)
|
|
103
|
+
|
|
104
|
+
return strQ
|
|
105
|
+
|
|
106
|
+
def AddTestRecordtoTestRunTable(self):
|
|
107
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_write_test_record_to_testrun_table.sql", "execution"))
|
|
108
|
+
|
|
109
|
+
return strQ
|
|
110
|
+
|
|
111
|
+
def PushTestRunStatusUpdateSQL(self):
|
|
112
|
+
# Runs on DK DB
|
|
113
|
+
strQ = self._ReplaceParms(read_template_sql_file("ex_update_test_record_in_testrun_table.sql", "execution"))
|
|
114
|
+
|
|
115
|
+
return strQ
|
|
116
|
+
|
|
117
|
+
def _GetTestQueryFromTemplate(self, strTemplateFile: str):
|
|
118
|
+
# Runs on Project DB
|
|
119
|
+
if strTemplateFile.endswith("_generic.sql"):
|
|
120
|
+
template_flavor = "generic"
|
|
121
|
+
else:
|
|
122
|
+
template_flavor = self.flavor
|
|
123
|
+
strQ = self._ReplaceParms(
|
|
124
|
+
read_template_sql_file(strTemplateFile, f"flavors/{template_flavor}/exec_query_tests")
|
|
125
|
+
)
|
|
126
|
+
return strQ
|
|
127
|
+
|
|
128
|
+
def _ConstructAggregateMatchParms(self):
|
|
129
|
+
# Prepares column list for SQL to compare sums of each column
|
|
130
|
+
|
|
131
|
+
# Split each comma separated column name into individual list items
|
|
132
|
+
cols = [s.strip() for s in self.dctTestParms["column_name"].split(",")]
|
|
133
|
+
_ = [s.strip() for s in self.dctTestParms["match_column_names"].split(",")]
|
|
134
|
+
|
|
135
|
+
# Surround all column names with SUM() to generate proper SQL syntax
|
|
136
|
+
self.list_sum_columns = ["SUM(" + i + ") as " + i for i in cols]
|
|
137
|
+
self.sum_columns = ", ".join(self.list_sum_columns)
|
|
138
|
+
|
|
139
|
+
self.list_match_sum_columns = ["SUM(" + i + ") as " + i for i in cols]
|
|
140
|
+
self.match_sum_columns = ", ".join(self.list_match_sum_columns)
|
|
141
|
+
|
|
142
|
+
# Suffix all column names with '< 0' to generate proper SQL WHERE/HAVING clause syntax
|
|
143
|
+
self.list_multi_column_error_condition = [i + " < 0" for i in cols]
|
|
144
|
+
self.multi_column_error_condition = " or ".join(self.list_multi_column_error_condition)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def GetTestQuery(self, booClean: bool):
|
|
148
|
+
strTestType = self.dctTestParms["test_type"]
|
|
149
|
+
strTemplate = self.dctTestParms["template_name"]
|
|
150
|
+
|
|
151
|
+
if strTemplate == "":
|
|
152
|
+
raise ValueError(f"No query template assigned to test_type {strTestType}")
|
|
153
|
+
|
|
154
|
+
strQ = self._GetTestQueryFromTemplate(strTemplate)
|
|
155
|
+
# Final replace to cover parm within CUSTOM_QUERY parm
|
|
156
|
+
strQ = strQ.replace("{DATA_SCHEMA}", self.dctTestParms["schema_name"])
|
|
157
|
+
|
|
158
|
+
if booClean:
|
|
159
|
+
strQ = CleanSQL(strQ)
|
|
160
|
+
return strQ
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from testgen.common import CleanSQL, date_service, get_template_files, read_template_sql_file
|
|
5
|
+
|
|
6
|
+
LOG = logging.getLogger("testgen")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CDeriveTestsSQL:
|
|
10
|
+
run_date = ""
|
|
11
|
+
project_code = ""
|
|
12
|
+
connection_id = ""
|
|
13
|
+
table_groups_id = ""
|
|
14
|
+
data_schema = ""
|
|
15
|
+
test_suite = ""
|
|
16
|
+
test_suite_id = ""
|
|
17
|
+
generation_set = ""
|
|
18
|
+
as_of_date = ""
|
|
19
|
+
sql_flavor = ""
|
|
20
|
+
dctTestParms: typing.ClassVar = {}
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
today = date_service.get_now_as_string()
|
|
24
|
+
self.run_date = today
|
|
25
|
+
self.as_of_date = today
|
|
26
|
+
self.dctTestParms = {}
|
|
27
|
+
|
|
28
|
+
def ClearTestParms(self):
|
|
29
|
+
# Test Set Parameters
|
|
30
|
+
self.dctTestParms = {}
|
|
31
|
+
|
|
32
|
+
def ReplaceParms(self, strInputString):
|
|
33
|
+
for parm, value in self.dctTestParms.items():
|
|
34
|
+
strInputString = strInputString.replace("{" + parm.upper() + "}", value)
|
|
35
|
+
|
|
36
|
+
strInputString = strInputString.replace("{PROJECT_CODE}", self.project_code)
|
|
37
|
+
strInputString = strInputString.replace("{SQL_FLAVOR}", self.sql_flavor)
|
|
38
|
+
strInputString = strInputString.replace("{CONNECTION_ID}", self.connection_id)
|
|
39
|
+
strInputString = strInputString.replace("{TABLE_GROUPS_ID}", self.table_groups_id)
|
|
40
|
+
strInputString = strInputString.replace("{RUN_DATE}", self.run_date)
|
|
41
|
+
strInputString = strInputString.replace("{TEST_SUITE}", self.test_suite)
|
|
42
|
+
strInputString = strInputString.replace("{TEST_SUITE_ID}", self.test_suite_id)
|
|
43
|
+
strInputString = strInputString.replace("{GENERATION_SET}", self.generation_set)
|
|
44
|
+
strInputString = strInputString.replace("{AS_OF_DATE}", self.as_of_date)
|
|
45
|
+
strInputString = strInputString.replace("{DATA_SCHEMA}", self.data_schema)
|
|
46
|
+
|
|
47
|
+
return strInputString
|
|
48
|
+
|
|
49
|
+
def GetInsertTestSuiteSQL(self, booClean):
|
|
50
|
+
strQuery = self.ReplaceParms(read_template_sql_file("gen_insert_test_suite.sql", "generation"))
|
|
51
|
+
if booClean:
|
|
52
|
+
strQuery = CleanSQL(strQuery)
|
|
53
|
+
|
|
54
|
+
return strQuery
|
|
55
|
+
|
|
56
|
+
def GetTestTypesSQL(self, booClean):
|
|
57
|
+
strQuery = self.ReplaceParms(read_template_sql_file("gen_standard_test_type_list.sql", "generation"))
|
|
58
|
+
if booClean:
|
|
59
|
+
strQuery = CleanSQL(strQuery)
|
|
60
|
+
|
|
61
|
+
return strQuery
|
|
62
|
+
|
|
63
|
+
def GetTestDerivationQueriesAsList(self, booClean):
|
|
64
|
+
# This assumes the queries run in no particular order,
|
|
65
|
+
# and will order them alphabetically by file name
|
|
66
|
+
lstQueries = sorted(
|
|
67
|
+
get_template_files(mask=r"^.*sql$", sub_directory="gen_funny_cat_tests"), key=lambda key: str(key)
|
|
68
|
+
)
|
|
69
|
+
lstTemplate = []
|
|
70
|
+
|
|
71
|
+
for script in lstQueries:
|
|
72
|
+
query = script.read_text("utf-8")
|
|
73
|
+
template = self.ReplaceParms(query)
|
|
74
|
+
lstTemplate.append(template)
|
|
75
|
+
|
|
76
|
+
if booClean:
|
|
77
|
+
lstTemplate = [CleanSQL(q) for q in lstTemplate]
|
|
78
|
+
|
|
79
|
+
if len(lstQueries) == 0:
|
|
80
|
+
LOG.warning("No funny CAT test generation templates were found")
|
|
81
|
+
|
|
82
|
+
return lstTemplate
|
|
83
|
+
|
|
84
|
+
def GetTestQueriesFromGenericFile(self, booClean: bool):
|
|
85
|
+
strQuery = self.ReplaceParms(read_template_sql_file("gen_standard_tests.sql", "generation"))
|
|
86
|
+
if booClean:
|
|
87
|
+
strQuery = CleanSQL(strQuery)
|
|
88
|
+
return strQuery
|
|
89
|
+
|
|
90
|
+
def GetDeleteOldTestsQuery(self, booClean: bool):
|
|
91
|
+
strQuery = self.ReplaceParms(read_template_sql_file("gen_delete_old_tests.sql", "generation"))
|
|
92
|
+
if booClean:
|
|
93
|
+
strQuery = CleanSQL(strQuery)
|
|
94
|
+
return strQuery
|