Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuu508 committed Sep 8, 2023
1 parent ee40cd8 commit 1881fa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hc/api/tests/test_notify_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_it_enforces_limit(self, mock_post: Mock) -> None:
self.assertEqual(email.to[0], "alice@example.org")
self.assertEqual(email.subject, "Monthly SMS Limit Reached")

@override_settings(TWILIO_FROM="+000")
@patch("hc.api.transports.curl.request")
def test_it_resets_limit_next_month(self, mock_post: Mock) -> None:
# At limit, but also into a new month
Expand All @@ -95,6 +96,7 @@ def test_it_resets_limit_next_month(self, mock_post: Mock) -> None:
self.channel.notify(self.check)
mock_post.assert_called_once()

@override_settings(TWILIO_FROM="+000")
@patch("hc.api.transports.curl.request")
def test_it_does_not_escape_special_characters(self, mock_post: Mock) -> None:
self.check.name = "Foo > Bar & Co"
Expand All @@ -115,6 +117,7 @@ def test_it_handles_disabled_down_notification(self, mock_post: Mock) -> None:
self.channel.notify(self.check)
mock_post.assert_not_called()

@override_settings(TWILIO_FROM="+000")
@patch("hc.api.transports.curl.request")
def test_it_sends_up_notification(self, mock_post: Mock) -> None:
payload = {"value": "+123123123", "up": True, "down": False}
Expand Down
2 changes: 2 additions & 0 deletions hc/front/tests/test_send_test_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import Mock, patch

from django.core import mail
from django.test.utils import override_settings

from hc.api.models import Channel, Notification
from hc.test import BaseTestCase
Expand Down Expand Up @@ -133,6 +134,7 @@ def test_it_checks_channel_ownership(self) -> None:
r = self.client.post(self.url, {}, follow=True)
self.assertEqual(r.status_code, 404)

@override_settings(TWILIO_FROM="+000")
@patch("hc.api.transports.curl.request")
def test_it_handles_up_only_sms_channel(self, mock_post: Mock) -> None:
mock_post.return_value.status_code = 200
Expand Down

0 comments on commit 1881fa1

Please sign in to comment.