Skip to content

Commit

Permalink
Prepare for unittest
Browse files Browse the repository at this point in the history
Create the basic directories and files needed for unittest.
  • Loading branch information
jose-caballero committed Jan 17, 2025
1 parent 4e7d058 commit b28eca7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Empty file.
20 changes: 20 additions & 0 deletions tests/lib/alertmanager_api/test_silence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from unittest.mock import MagicMock, patch

from structs.alertmanager.silence_details import SilenceDetails
from alertmanager_api.silence import AlertManagerAPI


@patch("alertmanager_api.silence.requests.post")
def test_schedule_silence_sucess(mock_post):
alertmanager_account = MagicMock()
class_instance = AlertManagerAPI(alertmanager_account)

silence = SilenceDetails("hostname", "starttitme", "endtime", "author", "comment")

mock_response = MagicMock()
mock_response.status_code = 201
mock_post.return_value = mock_response

class_instance.schedule_silence(silence)

mock_post.assert_called_once()

0 comments on commit b28eca7

Please sign in to comment.