コード例 #1
0
def test_ExpectationSuiteColumnSectionRenderer_render_header(
        titanic_profiled_name_column_expectations):
    remaining_expectations, content_blocks = ExpectationSuiteColumnSectionRenderer._render_header(
        titanic_profiled_name_column_expectations,  #["expectations"],
        [],
    )

    print(json.dumps(content_blocks, indent=2))
    assert content_blocks == [
        RenderedComponentContent(
            **{
                "content_block_type": "header",
                "header": "Name",
                "styling": {
                    "classes": ["col-12"],
                    "header": {
                        "classes": ["alert", "alert-secondary"]
                    }
                }
            })
    ]

    expectation_with_unescaped_dollar_sign = {
        "expectation_type": "expect_column_values_to_be_in_type_list",
        "kwargs": {
            "column":
            "Car Insurance Premiums ($)",
            "type_list": [
                "DOUBLE_PRECISION", "DoubleType", "FLOAT", "FLOAT4", "FLOAT8",
                "FloatType", "NUMERIC", "float"
            ],
            "result_format":
            "SUMMARY"
        },
        "meta": {
            "BasicDatasetProfiler": {
                "confidence": "very low"
            }
        }
    }
    remaining_expectations, content_blocks = ExpectationSuiteColumnSectionRenderer._render_header(
        [expectation_with_unescaped_dollar_sign], [])
    print(content_blocks)
    assert content_blocks[0] == {
        'content_block_type': 'header',
        'header': 'Car Insurance Premiums ($$)',
        'styling': {
            'classes': ['col-12'],
            'header': {
                'classes': ['alert', 'alert-secondary']
            }
        }
    }
コード例 #2
0
def test_ExpectationSuiteColumnSectionRenderer_render_header(titanic_profiled_name_column_expectations):
    remaining_expectations, content_blocks = ExpectationSuiteColumnSectionRenderer._render_header(
        titanic_profiled_name_column_expectations,
    )

    expected = {'content_block_type': 'header',
                'styling': {'classes': ['col-12'], 'header': {'classes': ['alert', 'alert-secondary']}},
                'header': {'content_block_type': 'string_template',
                           'string_template': {'template': 'Name', 'tag': 'h5', 'styling': {'classes': ['m-0']}}}}

    print(content_blocks.to_json_dict())

    assert content_blocks.to_json_dict() == expected

    expectation_with_unescaped_dollar_sign = ExpectationConfiguration(
      expectation_type="expect_column_values_to_be_in_type_list",
      kwargs={
        "column": "Car Insurance Premiums ($)",
        "type_list": [
          "DOUBLE_PRECISION",
          "DoubleType",
          "FLOAT",
          "FLOAT4",
          "FLOAT8",
          "FloatType",
          "NUMERIC",
          "float"
        ],
        "result_format": "SUMMARY"
      },
      meta={
        "BasicDatasetProfiler": {
          "confidence": "very low"
        }
      }
    )
    remaining_expectations, content_blocks = ExpectationSuiteColumnSectionRenderer._render_header(
        [expectation_with_unescaped_dollar_sign],
    )

    print(content_blocks.to_json_dict())
    expected = {
        'content_block_type': 'header',
        'styling': {
            'classes': ['col-12'],
            'header': {
                'classes': [
                    'alert', 'alert-secondary']}}, 'header': {'content_block_type': 'string_template',
                                                              'string_template': {
                                                                  'template': 'Car Insurance Premiums ($$)',
                                                                  'tag': 'h5',
                                                                  'styling': {'classes': ['m-0']}}}}
    assert content_blocks.to_json_dict() == expected