def test_render_asset_notes():
    # import pypandoc
    # print(pypandoc.convert_text("*hi*", to='html', format="md"))

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : "*hi*"
        }
    })
    print(result)
    assert result["content"] == ["*hi*"]

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : ["*alpha*", "_bravo_", "charlie"]
        }
    })
    print(result)
    assert result["content"] == ["*alpha*", "_bravo_", "charlie"]

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : {
                "format": "string",
                "content": ["*alpha*", "_bravo_", "charlie"]
            }
        }
    })
    print(result)
    assert result["content"] == ["*alpha*", "_bravo_", "charlie"]

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : {
                "format": "markdown",
                "content": "*alpha*"
            }
        }
    })
    print(result)
    assert result["content"] == ["<p><em>alpha</em></p>\n"]

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : {
                "format": "markdown",
                "content": ["*alpha*", "_bravo_", "charlie"]
            }
        }
    })
    print(result)
    assert result["content"] == ["<p><em>alpha</em></p>\n", "<p><em>bravo</em></p>\n", "<p>charlie</p>\n"]
def test_expectation_summary_in_render_asset_notes():
    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {},
        "expectations" : {}
    })
    print(result)
    assert result["content"] == ['This Expectation suite currently contains 0 total Expectations across 0 columns.']

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {
            "notes" : {
                "format": "markdown",
                "content": ["hi"]
            }
        },
        "expectations" : {}
    })
    print(result)
    assert result["content"] == [
        'This Expectation suite currently contains 0 total Expectations across 0 columns.',
        '<p>hi</p>\n',
    ]

    result = PrescriptivePageRenderer._render_asset_notes({
        "meta" : {},
        "expectations" : [
            {
                "expectation_type": "expect_table_row_count_to_be_between",
                "kwargs": { "min_value": 0, "max_value": None, }
            },
            {
                "expectation_type": "expect_column_to_exist",
                "kwargs": { "column": "x", }
            },
            {
                "expectation_type": "expect_column_to_exist",
                "kwargs": { "column": "y", }
            },
        ]
    })
    print(result)
    assert result["content"][0] == 'This Expectation suite currently contains 3 total Expectations across 2 columns.'
Ejemplo n.º 3
0
def test_render_profiled_fixture_expectations(
        tetanus_varicella_basic_dataset_profiler_expectations):
    rendered_json = PrescriptivePageRenderer.render(
        tetanus_varicella_basic_dataset_profiler_expectations)
    rendered_page = DefaultJinjaPageView.render(rendered_json)

    with open(
            './tests/render/output/test_render_profiled_fixture_expectations.html',
            'w') as f:
        f.write(rendered_page)

    assert rendered_page[:15] == "<!DOCTYPE html>"
    assert rendered_page[-7:] == "</html>"
Ejemplo n.º 4
0
def render(render_object):
    """Render a great expectations object to documentation.

    RENDER_OBJECT: path to a GE object to render
    """
    with open(render_object, "r") as infile:
        raw = json.load(infile)

    if "results" in raw:
        model = DescriptivePageRenderer.render(raw)
    else:
        model = PrescriptivePageRenderer.render(raw)
    print(DefaultJinjaPageView.render(model))
Ejemplo n.º 5
0
def test_render_profiled_fixture_expectations_with_distribution(
        titanic_dataset_profiler_expectations_with_distribution):
    # Tests sparkline
    rendered_json = PrescriptivePageRenderer.render(
        titanic_dataset_profiler_expectations_with_distribution)
    rendered_page = DefaultJinjaPageView.render(rendered_json)

    with open(
            './tests/render/output/titanic_dataset_profiler_expectations_with_distribution.html',
            'wb') as f:
        f.write(rendered_page.encode("utf-8"))

    assert rendered_page[:15] == "<!DOCTYPE html>"
    assert rendered_page[-7:] == "</html>"