예제 #1
0
def test_parse_check_statistics(check_stats, expectation):
    """Test that Checks are correctly parsed from check statistics."""
    if expectation is None:
        expectation = []
    checks = schema_statistics.parse_check_statistics(check_stats)
    if checks is None:
        checks = []
    assert set(checks) == set(expectation)
예제 #2
0
def test_parse_checks_and_statistics_no_param(extra_registered_checks):
    """Ensure that an edge case where a check does not have parameters is appropriately handled."""

    checks = [pa.Check.no_param_check()]
    expectation = {"no_param_check": {}}
    assert schema_statistics.parse_checks(checks) == expectation

    check_statistics = {check.name: check.statistics for check in checks}
    check_list = schema_statistics.parse_check_statistics(check_statistics)
    assert set(check_list) == set(checks)
예제 #3
0
def test_parse_checks_and_statistics_roundtrip(checks, expectation):
    """
    Test that parse checks correctly obtain statistics from checks and
    vice-versa.
    """
    if expectation is ValueError:
        with pytest.raises(ValueError):
            schema_statistics.parse_checks(checks)
        return
    assert schema_statistics.parse_checks(checks) == expectation

    check_statistics = {check.name: check.statistics for check in checks}
    check_list = schema_statistics.parse_check_statistics(check_statistics)
    assert set(check_list) == set(checks)