Beispiel #1
0
def test_ValidationResultsTableContentBlockRenderer_get_observed_value(
        evr_success):
    evr_no_result_key = {
        "success": True,
        "exception_info": {
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None
        },
        "expectation_config": {
            "expectation_type": "expect_table_row_count_to_be_between",
            "kwargs": {
                "min_value": 0,
                "max_value": None,
                "result_format": "SUMMARY"
            }
        }
    }

    evr_expect_column_values_to_not_be_null = {
        "success": True,
        "result": {
            "element_count": 1313,
            "unexpected_count": 1050,
            "unexpected_percent": 79.96953541508,
            "partial_unexpected_list": []
        },
        "exception_info": {
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None
        },
        "expectation_config": {
            "expectation_type": "expect_column_values_to_not_be_null",
            "kwargs": {
                "column": "Unnamed: 0",
                "mostly": 0.5,
                "result_format": "SUMMARY"
            }
        }
    }

    evr_expect_column_values_to_be_null = {
        "success": True,
        "result": {
            "element_count": 1313,
            "unexpected_count": 0,
            "unexpected_percent": 0.0,
            "partial_unexpected_list": []
        },
        "exception_info": {
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None
        },
        "expectation_config": {
            "expectation_type": "expect_column_values_to_be_null",
            "kwargs": {
                "column": "Unnamed: 0",
                "mostly": 0.5,
                "result_format": "SUMMARY"
            }
        }
    }

    # test _get_observed_value when evr["result"]["observed_value"] exists
    output_1 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_success)
    print(output_1)
    assert output_1 == "1,313"
    # test _get_observed_value when evr["result"] does not exist
    output_2 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_no_result_key)
    print(output_2)
    assert output_2 == "--"
    # test _get_observed_value for expect_column_values_to_not_be_null expectation type
    output_3 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_expect_column_values_to_not_be_null)
    print(output_3)
    assert output_3 == "≈20.03% not null"
    # test _get_observed_value for expect_column_values_to_be_null expectation type
    output_4 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_expect_column_values_to_be_null)
    print(output_4)
    assert output_4 == "100% null"
def test_ValidationResultsTableContentBlockRenderer_get_observed_value(
        evr_success):
    evr_no_result_key = ExpectationValidationResult(
        success=True,
        exception_info={
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None,
        },
        expectation_config=ExpectationConfiguration(
            expectation_type="expect_table_row_count_to_be_between",
            kwargs={
                "min_value": 0,
                "max_value": None,
                "result_format": "SUMMARY"
            },
        ),
    )

    evr_expect_column_values_to_not_be_null = ExpectationValidationResult(
        success=True,
        result={
            "element_count": 1313,
            "unexpected_count": 1050,
            "unexpected_percent": 79.96953541508,
            "partial_unexpected_list": [],
        },
        exception_info={
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None,
        },
        expectation_config=ExpectationConfiguration(
            expectation_type="expect_column_values_to_not_be_null",
            kwargs={
                "column": "Unnamed: 0",
                "mostly": 0.5,
                "result_format": "SUMMARY"
            },
        ),
    )

    evr_expect_column_values_to_be_null = ExpectationValidationResult(
        success=True,
        result={
            "element_count": 1313,
            "unexpected_count": 0,
            "unexpected_percent": 0.0,
            "partial_unexpected_list": [],
        },
        exception_info={
            "raised_exception": False,
            "exception_message": None,
            "exception_traceback": None,
        },
        expectation_config=ExpectationConfiguration(
            expectation_type="expect_column_values_to_be_null",
            kwargs={
                "column": "Unnamed: 0",
                "mostly": 0.5,
                "result_format": "SUMMARY"
            },
        ),
    )

    # test _get_observed_value when evr.result["observed_value"] exists
    output_1 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_success)
    assert output_1 == "1,313"
    # test _get_observed_value when evr.result does not exist
    output_2 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_no_result_key)
    assert output_2 == "--"
    # test _get_observed_value for expect_column_values_to_not_be_null expectation type
    output_3 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_expect_column_values_to_not_be_null)
    assert output_3 == "≈20.03% not null"
    # test _get_observed_value for expect_column_values_to_be_null expectation type
    output_4 = ValidationResultsTableContentBlockRenderer._get_observed_value(
        evr_expect_column_values_to_be_null)
    assert output_4 == "100% null"