def test_ProfilingResultsOverviewSectionRenderer_render_variable_types(
    datetime_column_evrs, ):
    """Build a type table from a type expectations and assert that we correctly infer column type
    for datetime. Other types would be useful to test for as well."""

    content_blocks = []
    ProfilingResultsOverviewSectionRenderer._render_variable_types(
        datetime_column_evrs, content_blocks)
    assert len(content_blocks) == 1
    type_table = content_blocks[0].table
    filtered = [row for row in type_table if row[0] == "datetime"]
    assert filtered == [["datetime", "2"]]
예제 #2
0
def test_ProfilingResultsOverviewSectionRenderer_empty_type_list():
    # This rather specific test is a reaction to the error documented in #679
    validation = ExpectationSuiteValidationResult(
        results=[
            ExpectationValidationResult(
                success=True,
                result={
                    'observed_value': "VARIANT",  # Note this is NOT a recognized type by many backends
                },
                exception_info={
                    'raised_exception': False, 'exception_message': None, 'exception_traceback': None
                },
                expectation_config=ExpectationConfiguration(
                    expectation_type='expect_column_values_to_be_in_type_list',
                    kwargs={
                        'column': 'live', 'type_list': None, 'result_format': 'SUMMARY'
                    },
                    meta={'BasicDatasetProfiler': {'confidence': 'very low'}}
                )
            )
        ]
    )

    result = ProfilingResultsOverviewSectionRenderer().render(validation)

    # Find the variable types content block:
    types_table = [
        block.table for block in result.content_blocks
        if block.content_block_type == "table" and block.header.string_template["template"] == "Variable types"
    ][0]
    assert ["unknown", "1"] in types_table
def test_ProfilingResultsOverviewSectionRenderer_empty_type_list():
    # This rather specific test is a reaction to the error documented in #679
    validation = {
        "results": [
            {
                'success': True,
                'result': {
                    'observed_value': "VARIANT",  # Note this is NOT a recognized type
                },
                'exception_info': {
                    'raised_exception': False, 'exception_message': None, 'exception_traceback': None
                },
                'expectation_config': {
                    'expectation_type': 'expect_column_values_to_be_in_type_list',
                    'kwargs': {
                        'column': 'live', 'type_list': None, 'result_format': 'SUMMARY'
                    },
                    'meta': {'BasicDatasetProfiler': {'confidence': 'very low'}}
                }
            }
        ]
    }

    result = ProfilingResultsOverviewSectionRenderer().render(validation)

    # Find the variable types content block:
    types_table = [
        block["table"] for block in result["content_blocks"]
        if block["content_block_type"] == "table" and block["header"] == "Variable types"
    ][0]
    assert ["unknown", "1"] in types_table