Coverage for libs/sdc_etl_libs/sdc_data_validation/data_validation_quality_test.py : 25%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1""" Base class for data validation tests """
3from sdc_etl_libs.sdc_data_validation.data_validation_enums import ValidationTestTypes, ValidationRunResultStatus, \
4 ValidationRunResultReason
7class QualityValidationTest:
9 def __init__(self):
11 pass
13 def run_quality_validation_test(self):
14 """
16 """
18 if self.run_against == "dataframe":
19 results = self.run_against_dataframe()
21 elif self.run_against == "database":
22 results = self.run_against_database()
24 cols_failed = [result for result in results if result[1] > 0]
25 cols_passed = [result for result in results if result[1] == 0]
26 if cols_failed:
27 self.capture_result_record(
28 test_number_=self.test_number,
29 result_status_=ValidationRunResultStatus.FAIL,
30 result_reason_=ValidationRunResultStatus.FAIL,
31 test_name_=self.validation_test_name,
32 message_=f'{len(cols_failed):,} column(s) had violations: {cols_failed}'
33 )
34 if cols_passed:
35 self.capture_result_record(
36 test_number_=self.test_number,
37 result_status_=ValidationRunResultStatus.PASS,
38 result_reason_=ValidationRunResultStatus.PASS,
39 test_name_=self.validation_test_name,
40 message_=f'{len(cols_passed):,} column(s) had no violations: {cols_passed}'
41 )
42 else:
43 self.capture_result_record(
44 test_number_=self.test_number,
45 result_status_=ValidationRunResultStatus.PASS,
46 result_reason_=ValidationRunResultStatus.PASS,
47 test_name_=self.validation_test_name,
48 message_=f'All columns tested passed with no violations'
49 )