From 19ee3c42b651fb9942d50635a3d18b3acbe544a8 Mon Sep 17 00:00:00 2001 From: PhracturedBlue Date: Tue, 8 Aug 2017 14:37:16 -0700 Subject: [PATCH] Add longer text strings to mailbox demo to test string truncation (#8893) * Add longer text strings to mailbox demo to test string truncation in frontend * Remove lorem ipsum txt file * Use format instead of % --- homeassistant/components/mailbox/demo.py | 4 +++- tests/components/mailbox/test_init.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/mailbox/demo.py b/homeassistant/components/mailbox/demo.py index aba2ca3bdaf..ccb371de2f8 100644 --- a/homeassistant/components/mailbox/demo.py +++ b/homeassistant/components/mailbox/demo.py @@ -31,10 +31,12 @@ class DemoMailbox(Mailbox): """Initialize Demo mailbox.""" super().__init__(hass, name) self._messages = {} + txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " for idx in range(0, 10): msgtime = int(dt.as_timestamp( dt.utcnow()) - 3600 * 24 * (10 - idx)) - msgtxt = "This is recorded message # %d" % (idx) + msgtxt = "Message {}. {}".format( + idx + 1, txt * (1 + idx * (idx % 2))) msgsha = sha1(msgtxt.encode('utf-8')).hexdigest() msg = {"info": {"origtime": msgtime, "callerid": "John Doe <212-555-1212>", diff --git a/tests/components/mailbox/test_init.py b/tests/components/mailbox/test_init.py index 566feeb61d1..c9267fa8e8e 100644 --- a/tests/components/mailbox/test_init.py +++ b/tests/components/mailbox/test_init.py @@ -47,7 +47,8 @@ def test_get_messages_from_mailbox(mock_http_client): def test_get_media_from_mailbox(mock_http_client): """Get audio from mailbox.""" mp3sha = "3f67c4ea33b37d1710f772a26dd3fb43bb159d50" - msgtxt = "This is recorded message # 1" + msgtxt = ("Message 1. " + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ") msgsha = sha1(msgtxt.encode('utf-8')).hexdigest() url = "/api/mailbox/media/DemoMailbox/%s" % (msgsha) @@ -60,8 +61,10 @@ def test_get_media_from_mailbox(mock_http_client): @asyncio.coroutine def test_delete_from_mailbox(mock_http_client): """Get audio from mailbox.""" - msgtxt1 = "This is recorded message # 1" - msgtxt2 = "This is recorded message # 2" + msgtxt1 = ("Message 1. " + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ") + msgtxt2 = ("Message 3. " + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ") msgsha1 = sha1(msgtxt1.encode('utf-8')).hexdigest() msgsha2 = sha1(msgtxt2.encode('utf-8')).hexdigest()