def test_complete_enabled(self, mock_head):
     """Test for `complete` method, case: Cronitor enabled"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.complete("cRoNiD")
     mock_head.assert_called_once_with(
         "https://cronitor.link/cRoNiD/complete", params=None, timeout=10)
 def test_complete_disabled(self, mock_head):
     """Test for `complete` method, case: Cronitor disabled"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.complete("cRoNiD")
     mock_head.assert_not_called()
     cronitor.logger.warning.assert_has_calls(
         [mock.call("Cronitor request ignored (disabled in settings).")])
 def test_fail_disabled(self, mock_head):
     """Test for `fail` method, case: Cronitor disabled"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.fail("cRoNiD", msg="RuntimeError: test message")
     mock_head.assert_not_called()
     cronitor.logger.warning.assert_has_calls(
         [mock.call("Cronitor request ignored (disabled in settings).")])
 def test_fail_enabled(self, mock_head):
     """Test for `fail` method, case: Cronitor enabled"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.fail("cRoNiD", msg="RuntimeError: test message")
     mock_head.assert_called_once_with(
         "https://cronitor.link/cRoNiD/fail",
         params={"msg": "RuntimeError: test message"},
         timeout=10,
     )
 def test_complete_failed(self, mock_head):
     """Test for `complete` method, case: Cronitor enabled, request failed"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.complete("cRoNiD")
     mock_head.assert_called_once_with(
         "https://cronitor.link/cRoNiD/complete", params=None, timeout=10)
     cronitor.logger.warning.assert_has_calls([
         mock.call("Cronitor request failed: "
                   "https://cronitor.link/cRoNiD/complete "
                   "ConnectTimeout: msg")
     ])
 def test_fail_failed(self, mock_head):
     """Test for `fail` method, case: Cronitor enabled, request failed"""
     cronitor = Cronitor()
     cronitor.logger = mock.MagicMock()
     cronitor.fail("cRoNiD", msg="RuntimeError: test message")
     mock_head.assert_called_once_with(
         "https://cronitor.link/cRoNiD/fail",
         params={"msg": "RuntimeError: test message"},
         timeout=10,
     )
     cronitor.logger.warning.assert_has_calls([
         mock.call("Cronitor request failed: "
                   "https://cronitor.link/cRoNiD/fail "
                   "ConnectTimeout: msg")
     ])
Exemple #7
0
 def __init__(self, **kwargs):
     self.data_dir = kwargs.get("data_dir", config("CRONMAN_DATA_DIR"))
     self.debug = kwargs.get("debug", bool_param(config("CRONMAN_DEBUG")))
     self.cronitor = Cronitor()
     self.sentry = Sentry()
     self.slack = Slack()
     ensure_dir(self.data_dir)
     self.logger = kwargs.get("logger", logger)