* #4421 - Forced icons to be displayed via SSL to avoid Mixed Content warnings * Fixed houndci-bot whitespace * Using regex to replace http:// for https:// * Created assert test to verify https translationpull/4584/head
parent
2a7bc0e55c
commit
61653a517d
|
@ -7,6 +7,7 @@ https://home-assistant.io/components/sensor.wunderground/
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import re
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -172,7 +173,8 @@ class WUndergroundSensor(Entity):
|
|||
def entity_picture(self):
|
||||
"""Return the entity picture."""
|
||||
if self._condition == 'weather':
|
||||
return self.rest.data['icon_url']
|
||||
url = self.rest.data['icon_url']
|
||||
return re.sub(r'^http://', 'https://', url, flags=re.IGNORECASE)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -25,7 +25,7 @@ VALID_CONFIG = {
|
|||
|
||||
FEELS_LIKE = '40'
|
||||
WEATHER = 'Clear'
|
||||
ICON_URL = 'http://icons.wxug.com/i/c/k/clear.gif'
|
||||
HTTPS_ICON_URL = 'https://icons.wxug.com/i/c/k/clear.gif'
|
||||
ALERT_MESSAGE = 'This is a test alert message'
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ def mocked_requests_get(*args, **kwargs):
|
|||
},
|
||||
"feelslike_c": FEELS_LIKE,
|
||||
"weather": WEATHER,
|
||||
"icon_url": ICON_URL,
|
||||
"icon_url": 'http://icons.wxug.com/i/c/k/clear.gif',
|
||||
"display_location": {
|
||||
"city": "Holly Springs",
|
||||
"country": "US",
|
||||
|
@ -150,7 +150,7 @@ class TestWundergroundSetup(unittest.TestCase):
|
|||
device.update()
|
||||
self.assertTrue(str(device.name).startswith('PWS_'))
|
||||
if device.name == 'PWS_weather':
|
||||
self.assertEqual(ICON_URL, device.entity_picture)
|
||||
self.assertEqual(HTTPS_ICON_URL, device.entity_picture)
|
||||
self.assertEqual(WEATHER, device.state)
|
||||
self.assertIsNone(device.unit_of_measurement)
|
||||
elif device.name == 'PWS_alerts':
|
||||
|
|
Loading…
Reference in New Issue