def test_null_rows(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() with pytest.warns(None) as recorded: assert testcolumn.null_row_numbers == set(result) assert recorded.list == []
def test_value_range(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() with pytest.warns(None) as recorded: assert testcolumn.value_range == result assert recorded.list == []
def test_validate_contraint(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() with pytest.warns(None) as recorded: assert testcolumn._ColumnReport__constraint_violated_pairs == result assert recorded.list == []
def test_dnulls(descriptor, values, resnulls, rescorr): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() with pytest.warns(None) as recorded: assert testcolumn.dnulls == resnulls assert testcolumn.dcorrections == rescorr assert recorded.list == []
def test_calc_nulls_nocorrection(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() totest = [] totest.append(testcolumn.not_nulls_total) totest.append(testcolumn.nulls_total) with pytest.warns(None) as recorded: assert totest == result assert recorded.list == []
def test_suggestions_c(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() totest = [ sugestion.newvalue for sugestion in testcolumn._ColumnReport__csuggestions ] with pytest.warns(None) as recorded: assert totest == result assert recorded.list == []
def __create_reports(self): """Create column reports.""" for header_name in self.__table.actual_headers: try: field_index = self.__table.schema.field_names.index( header_name) qcfield = self.__table.schema.fields[field_index] raw_values = self.__table.column_values(qcfield.name) column_report = ColumnReport(raw_values, qcfield, threshold=self.__threshold) column_report.validate() self.__columnreports[qcfield.name] = column_report except (ValueError, QCToolException) as e: pass
def test_corrected_values(descriptor, values, result): testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() testcolumn.apply_corrections() with pytest.warns(None) as recorded: assert testcolumn.corrected_values == result assert recorded.list == []
def test_cnulls(descriptor, values, resnulls, rescorr, path): app_path = os.path.abspath(os.path.dirname(__file__)) report_path = os.path.join(app_path, path) testfield = QcField(descriptor) testcolumn = ColumnReport(values, testfield) testcolumn.validate() testcolumn.printpdf(report_path) with pytest.warns(None) as recorded: assert testcolumn.cnulls == resnulls assert testcolumn.ccorrections == rescorr assert recorded.list == []