Skip to content

Commit

Permalink
Only test for batch kwargs text
Browse files Browse the repository at this point in the history
  • Loading branch information
roblim committed Aug 9, 2019
1 parent 2576a73 commit 28bd8b6
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions tests/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,61 +100,28 @@ def test_build_slack_notification_request_with_successful_validation(validation_


def test_build_slack_notification_request_with_successful_validation_and_batch_kwargs(validation_json):
validation_json["meta"]["batch_kwargs"] = {
batch_kwargs = {
"path": "/Users/user/some_path/some_file.csv",
"timestamp": "1565286704.3622668",
"sep": None,
"engine": "python"
}
validation_json["meta"]["batch_kwargs"] = batch_kwargs

with mock.patch("datetime.datetime") as mock_datetime:
mock_datetime.strftime.return_value = "05/05/19 12:12:12"
obs = build_slack_notification_request(validation_json)

assert isinstance(obs, dict)
print(obs)
expected = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Validated batch from data asset:* `diabetes_raw_csv`\n*Status: Success :tada:*\n33 of 44 expectations were met\n\n",
},
},
{
'type': 'section',
'text': {
'type': 'mrkdwn',
'text': 'Batch kwargs: {\n "path": "/Users/user/some_path/some_file.csv",\n "timestamp": "1565286704.3622668",\n "sep": null,\n "engine": "python"\n}'
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "- *Validation Report*: s3://my_bucket/blah.json",
},
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "- *Validation data asset*: s3://my_bucket/blah.csv",
},
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Great Expectations run id 7 ran at 05/05/19 12:12:12",
}
],
},
]
}
assertDeepAlmostEqual(expected, obs)
assert len(obs["blocks"]) == 5
batch_kwargs_text = obs["blocks"][1]["text"]["text"]
for key, val in batch_kwargs.items():
assert key in batch_kwargs_text
if val is not None:
assert val in batch_kwargs_text
else:
assert 'null' in batch_kwargs_text


def test_build_slack_notification_request_with_failed_validation(validation_json):
Expand Down

0 comments on commit 28bd8b6

Please sign in to comment.