def test_json_to_slack_mrkdwn_str(self): """SlackOutput - JSON to Slack mrkdwn, Simple String""" simple_str = 'value to format' result = SlackOutput._json_to_slack_mrkdwn(simple_str, 0) assert_equal(len(result), 1) assert_equal(result[0], simple_str)
def test_json_to_slack_mrkdwn_dict(self): """SlackOutput - JSON to Slack mrkdwn, Simple Dict""" simple_dict = OrderedDict([('test_key_01', 'test_value_01'), ('test_key_02', 'test_value_02')]) result = SlackOutput._json_to_slack_mrkdwn(simple_dict, 0) assert_equal(len(result), 2) assert_equal(result[1], '*test_key_02:* test_value_02')
def test_json_to_slack_mrkdwn_list(self): """SlackOutput - JSON to Slack mrkdwn, Simple List""" simple_list = ['test_value_01', 'test_value_02'] result = SlackOutput._json_to_slack_mrkdwn(simple_list, 0) assert_equal(len(result), 2) assert_equal(result[0], '*[1]* test_value_01') assert_equal(result[1], '*[2]* test_value_02')
def test_json_to_slack_mrkdwn_nested_dict(self): """SlackOutput - JSON to Slack mrkdwn, Nested Dict""" nested_dict = OrderedDict([ ('root_key_01', 'root_value_01'), ('root_02', 'root_value_02'), ('root_nested_01', OrderedDict([('nested_key_01', 100), ('nested_key_02', 200), ('nested_nested_01', OrderedDict([('nested_nested_key_01', 300)]))])) ]) result = SlackOutput._json_to_slack_mrkdwn(nested_dict, 0) assert_equal(len(result), 7) assert_equal(result[2], '*root_nested_01:*') assert_equal(Counter(result[4])['\t'], 1) assert_equal(Counter(result[6])['\t'], 2)
def test_json_to_slack_mrkdwn_multi_nested(self): """SlackOutput - JSON to Slack mrkdwn, Multi-type Nested""" nested_dict = OrderedDict([ ('root_key_01', 'root_value_01'), ('root_02', 'root_value_02'), ('root_nested_01', OrderedDict([('nested_key_01', 100), ('nested_key_02', 200), ('nested_nested_01', OrderedDict([('nested_nested_key_01', [6161, 1051, 51919])]))])) ]) result = SlackOutput._json_to_slack_mrkdwn(nested_dict, 0) assert_equal(len(result), 10) assert_equal(result[2], '*root_nested_01:*') assert_equal(Counter(result[4])['\t'], 1) assert_equal(result[-1], '\t\t\t*[3]* 51919')