def test_SlackRenderer(): validation_result_suite = ExpectationSuiteValidationResult( results=[], success=True, statistics={ 'evaluated_expectations': 0, 'successful_expectations': 0, 'unsuccessful_expectations': 0, 'success_percent': None }, meta={ 'great_expectations.__version__': 'v0.8.0__develop', 'data_asset_name': { 'datasource': 'x', 'generator': 'y', 'generator_asset': 'z' }, 'expectation_suite_name': 'default', 'run_id': '2019-09-25T060538.829112Z' }) rendered_output = SlackRenderer().render(validation_result_suite) print(rendered_output) expected_renderer_output = { 'blocks': [{ 'type': 'section', 'text': { 'type': 'mrkdwn', 'text': '*Batch Validation Status*: Success :tada:\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Batch ID*: `None`\n*Timestamp*: `09/24/2019 23:18:36`\n*Summary*: *0* of *0* expectations were met' } }, { 'type': 'divider' }, { 'type': 'context', 'elements': [{ 'type': 'mrkdwn', 'text': 'Learn how to review validation results: https://docs.greatexpectations.io/en/latest/features/validation.html#reviewing-validation-results' }] }], 'text': 'default: Success :tada:' } # We're okay with system variation in locales (OS X likes 24 hour, but not Travis) expected_renderer_output['blocks'][0]['text']['text'] = \ expected_renderer_output['blocks'][0]['text']['text'].replace('09/24/2019 11:18:36 PM', 'LOCALEDATE') expected_renderer_output['blocks'][0]['text']['text'] = \ expected_renderer_output['blocks'][0]['text']['text'].replace('09/24/2019 23:18:36', 'LOCALEDATE') rendered_output['blocks'][0]['text']['text'] = \ rendered_output['blocks'][0]['text']['text'].replace('09/24/2019 11:18:36 PM', 'LOCALEDATE') rendered_output['blocks'][0]['text']['text'] = \ rendered_output['blocks'][0]['text']['text'].replace('09/24/2019 23:18:36', 'LOCALEDATE') assert rendered_output == expected_renderer_output
def test_SlackRenderer(): ##### ##### # # Skipping for PY2 # ##### ##### if PY2: pytest.skip("skipping test_SlackRenderer for PY2") validation_result_suite = { 'results': [], 'success': True, 'statistics': { 'evaluated_expectations': 0, 'successful_expectations': 0, 'unsuccessful_expectations': 0, 'success_percent': None }, 'meta': { 'great_expectations.__version__': 'v0.8.0__develop', 'data_asset_name': { 'datasource': 'x', 'generator': 'y', 'generator_asset': 'z' }, 'expectation_suite_name': 'default', 'run_id': '2019-09-25T060538.829112Z' } } expected_renderer_output = { 'blocks': [{ 'type': 'section', 'text': { 'type': 'mrkdwn', 'text': "*Batch Validation Status*: Success :tada:\n*Data Asset:* `{'datasource': 'x', 'generator': 'y', 'generator_asset': 'z'}`\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Timestamp*: `09/24/19 23:18:36`\n*Summary*: *0* of *0* expectations were met" } }, { 'type': 'divider' }, { 'type': 'context', 'elements': [{ 'type': 'mrkdwn', 'text': 'Learn how to review validation results: https://docs.greatexpectations.io/en/latest/features/validation.html#reviewing-validation-results' }] }], 'text': "{'datasource': 'x', 'generator': 'y', 'generator_asset': 'z'}: Success :tada:" } renderer_output = SlackRenderer().render(validation_result_suite) assert renderer_output == expected_renderer_output
def test_SlackRenderer_get_report_element(): slack_renderer = SlackRenderer() # these should all be caught assert slack_renderer._get_report_element(docs_link=None) is None assert slack_renderer._get_report_element(docs_link=1) is None assert slack_renderer._get_report_element(docs_link=slack_renderer) is None # this should work assert slack_renderer._get_report_element( docs_link="i_should_work") is not None
def test_SlackRenderer_validation_results_with_datadocs(): validation_result_suite = ExpectationSuiteValidationResult( results=[], success=True, statistics={ "evaluated_expectations": 0, "successful_expectations": 0, "unsuccessful_expectations": 0, "success_percent": None, }, meta={ "great_expectations_version": "v0.8.0__develop", "data_asset_name": { "datasource": "x", "generator": "y", "generator_asset": "z", }, "expectation_suite_name": "default", "run_id": "2019-09-25T060538.829112Z", }, ) rendered_output = SlackRenderer().render(validation_result_suite) expected_output = { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*Batch Validation Status*: Success :tada:\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Batch ID*: `None`\n*Summary*: *0* of *0* expectations were met", }, }, {"type": "divider"}, { "type": "context", "elements": [ { "type": "mrkdwn", "text": "Learn how to review validation results in Data Docs: https://docs.greatexpectations.io/en/latest/guides/tutorials/getting_started/set_up_data_docs.html", } ], }, ], "text": "default: Success :tada:", } assert rendered_output == expected_output data_docs_pages = {"local_site": "file:///localsite/index.html"} notify_with = ["local_site"] rendered_output = SlackRenderer().render( validation_result_suite, data_docs_pages, notify_with ) expected_output = { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*Batch Validation Status*: Success :tada:\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Batch ID*: `None`\n*Summary*: *0* of *0* expectations were met", }, }, { "type": "section", "text": { "type": "mrkdwn", "text": "*DataDocs* can be found here: `file:///localsite/index.html` \n (Please copy and paste link into a browser to view)\n", }, }, {"type": "divider"}, { "type": "context", "elements": [ { "type": "mrkdwn", "text": "Learn how to review validation results in Data Docs: https://docs.greatexpectations.io/en/latest/guides/tutorials/getting_started/set_up_data_docs.html", } ], }, ], "text": "default: Success :tada:", } assert rendered_output == expected_output # not configured notify_with = ["fake_site"] rendered_output = SlackRenderer().render( validation_result_suite, data_docs_pages, notify_with ) expected_output = { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*Batch Validation Status*: Success :tada:\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Batch ID*: `None`\n*Summary*: *0* of *0* expectations were met", }, }, { "type": "section", "text": { "type": "mrkdwn", "text": "*ERROR*: Slack is trying to provide a link to the following DataDocs: `fake_site`, but it is not configured under `data_docs_sites` in the `great_expectations.yml`\n", }, }, {"type": "divider"}, { "type": "context", "elements": [ { "type": "mrkdwn", "text": "Learn how to review validation results in Data Docs: https://docs.greatexpectations.io/en/latest/guides/tutorials/getting_started/set_up_data_docs.html", } ], }, ], "text": "default: Success :tada:", } assert rendered_output == expected_output
def test_SlackRenderer(): validation_result_suite = ExpectationSuiteValidationResult( results=[], success=True, statistics={ "evaluated_expectations": 0, "successful_expectations": 0, "unsuccessful_expectations": 0, "success_percent": None, }, meta={ "great_expectations.__version__": "v0.8.0__develop", "data_asset_name": { "datasource": "x", "generator": "y", "generator_asset": "z", }, "expectation_suite_name": "default", "run_id": "2019-09-25T060538.829112Z", }, ) rendered_output = SlackRenderer().render(validation_result_suite) print(rendered_output) expected_renderer_output = { "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*Batch Validation Status*: Success :tada:\n*Expectation suite name*: `default`\n*Run ID*: `2019-09-25T060538.829112Z`\n*Batch ID*: `None`\n*Timestamp*: `09/24/2019 23:18:36`\n*Summary*: *0* of *0* expectations were met", }, }, { "type": "divider" }, { "type": "context", "elements": [{ "type": "mrkdwn", "text": "Learn how to review validation results in Data Docs: https://docs.greatexpectations.io/en/latest/tutorials/getting_started/set_up_data_docs.html#_getting_started__set_up_data_docs", }], }, ], "text": "default: Success :tada:", } # We're okay with system variation in locales (OS X likes 24 hour, but not Travis) expected_renderer_output["blocks"][0]["text"][ "text"] = expected_renderer_output["blocks"][0]["text"][ "text"].replace("09/24/2019 11:18:36 PM", "LOCALEDATE") expected_renderer_output["blocks"][0]["text"][ "text"] = expected_renderer_output["blocks"][0]["text"][ "text"].replace("09/24/2019 23:18:36", "LOCALEDATE") rendered_output["blocks"][0]["text"]["text"] = rendered_output["blocks"][ 0]["text"]["text"].replace("09/24/2019 11:18:36 PM UTC", "LOCALEDATE") rendered_output["blocks"][0]["text"]["text"] = rendered_output["blocks"][ 0]["text"]["text"].replace("09/24/2019 23:18:36 UTC", "LOCALEDATE") assert rendered_output == expected_renderer_output