diff --git a/homeassistant/components/rss_feed_template/__init__.py b/homeassistant/components/rss_feed_template/__init__.py index 3b88f9c0288..4dcbf7fe048 100644 --- a/homeassistant/components/rss_feed_template/__init__.py +++ b/homeassistant/components/rss_feed_template/__init__.py @@ -81,24 +81,31 @@ class RssView(HomeAssistantView): """Generate the RSS view XML.""" response = '\n\n' - response += "\n" + response += '\n' + response += " \n" if self._title is not None: - response += " %s\n" % escape( + response += " %s\n" % escape( self._title.async_render(parse_result=False) ) + else: + response += " Home Assistant\n" + + response += " https://www.home-assistant.io/integrations/rss_feed_template/\n" + response += " Home automation feed\n" for item in self._items: - response += " \n" + response += " \n" if "title" in item: - response += " " + response += " <title>" response += escape(item["title"].async_render(parse_result=False)) response += "\n" if "description" in item: - response += " " + response += " " response += escape(item["description"].async_render(parse_result=False)) response += "\n" - response += " \n" + response += " \n" + response += " \n" response += "\n" return web.Response(body=response, content_type=CONTENT_TYPE_XML) diff --git a/tests/components/rss_feed_template/test_init.py b/tests/components/rss_feed_template/test_init.py index bdc894c3343..ffdb4e5ba9a 100644 --- a/tests/components/rss_feed_template/test_init.py +++ b/tests/components/rss_feed_template/test_init.py @@ -46,6 +46,9 @@ async def test_get_rss_feed(mock_http_client, hass): text = await resp.text() xml = ElementTree.fromstring(text) - assert xml[0].text == "feed title is a_state_1" - assert xml[1][0].text == "item title is a_state_2" - assert xml[1][1].text == "desc a_state_3" + feed_title = xml.find("./channel/title").text + item_title = xml.find("./channel/item/title").text + item_description = xml.find("./channel/item/description").text + assert feed_title == "feed title is a_state_1" + assert item_title == "item title is a_state_2" + assert item_description == "desc a_state_3"