Example #1
0
def test_generate_slack_message():
    outage = get_outage()
    announcement = Announcement(outage=outage, channel_id="unittest")

    attachment = generate_slack_message(outage, announcement)[0]
    assert len(attachment["actions"]) == 5
    assert attachment["title"] == "Unittest-system incident"
Example #2
0
def test_generate_slack_message_dedicated_channel_id():
    outage = get_outage()
    announcement = Announcement(
        outage=outage, channel_id="unittest", dedicated_channel_id="unittest-dedicated"
    )

    attachment = generate_slack_message(outage, announcement)[0]
    action_names = [action["name"] for action in attachment["actions"]]
    assert "createchannel" not in action_names
Example #3
0
def test_outage_changed(mocked_delay):
    outage = get_outage()
    try:
        Announcement.objects.get(pk=outage.pk)
    except ObjectDoesNotExist:
        pytest.fail("Announcement should have been created")
    assert mocked_delay.call_count == 1  # called after creation

    outage.eta = 15
    outage.save()
    assert mocked_delay.call_count == 2  # called after change
Example #4
0
def test_solution_changed(mock_delay):
    get_outage(with_solution=True)
    assert mock_delay.call_count == 2  # called after outage creation and then
Example #5
0
def test_outage_systems_changed(mock_delay):
    get_outage()
    assert mock_delay.call_count == 1  # called by outage_changed after creation
Example #6
0
def test_generate_slack_message_resolved():
    outage = get_outage(with_solution=True)
    announcement = Announcement(outage=outage, channel_id="unittest")

    attachment = generate_slack_message(outage, announcement)[0]
    assert attachment["color"] == "good"