forked from GithubBackups/healthchecks
Replace non-breaking spaces with regular spaces for cheaper SMS messages.
This commit is contained in:
parent
31353fe24c
commit
1851cc7af3
@ -314,6 +314,8 @@ class NotifyTestCase(BaseTestCase):
|
|||||||
@patch("hc.api.transports.requests.request")
|
@patch("hc.api.transports.requests.request")
|
||||||
def test_sms(self, mock_post):
|
def test_sms(self, mock_post):
|
||||||
self._setup_data("sms", "+1234567890")
|
self._setup_data("sms", "+1234567890")
|
||||||
|
self.check.last_ping = now() - td(hours=2)
|
||||||
|
|
||||||
mock_post.return_value.status_code = 200
|
mock_post.return_value.status_code = 200
|
||||||
|
|
||||||
self.channel.notify(self.check)
|
self.channel.notify(self.check)
|
||||||
@ -322,6 +324,7 @@ class NotifyTestCase(BaseTestCase):
|
|||||||
args, kwargs = mock_post.call_args
|
args, kwargs = mock_post.call_args
|
||||||
payload = kwargs["data"]
|
payload = kwargs["data"]
|
||||||
self.assertEqual(payload["To"], "+1234567890")
|
self.assertEqual(payload["To"], "+1234567890")
|
||||||
|
self.assertFalse(u"\xa0" in payload["Body"])
|
||||||
|
|
||||||
# sent SMS counter should go up
|
# sent SMS counter should go up
|
||||||
self.profile.refresh_from_db()
|
self.profile.refresh_from_db()
|
||||||
|
@ -11,7 +11,9 @@ from hc.lib import emails
|
|||||||
|
|
||||||
def tmpl(template_name, **ctx):
|
def tmpl(template_name, **ctx):
|
||||||
template_path = "integrations/%s" % template_name
|
template_path = "integrations/%s" % template_name
|
||||||
return render_to_string(template_path, ctx).strip()
|
# \xa0 is non-breaking space. It causes SMS messages to use UCS2 encoding
|
||||||
|
# and cost twice the money.
|
||||||
|
return render_to_string(template_path, ctx).strip().replace(u"\xa0", " ")
|
||||||
|
|
||||||
|
|
||||||
class Transport(object):
|
class Transport(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user