Remove unnecessary string literal concatenations (#30360)
This commit is contained in:
1 parent
cac750066a
commit
e6388e186c
183 files changed
+362
-393
No files matched your search
@@ -302,7 +302,7 @@ def test_aprs_listener_rx_msg_no_position():
|
||||
def test_setup_scanner():
|
||||
"""Test setup_scanner."""
|
||||
with patch(
|
||||
"homeassistant.components." "aprs.device_tracker.AprsListenerThread"
|
||||
"homeassistant.components.aprs.device_tracker.AprsListenerThread"
|
||||
) as listener:
|
||||
hass = get_test_home_assistant()
|
||||
hass.start()
|
||||
|
||||
@@ -39,7 +39,7 @@ async def test_if_fires_using_at(hass, calls):
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.platform }} - " "{{ trigger.now.hour }}"
|
||||
"some": "{{ trigger.platform }} - {{ trigger.now.hour }}"
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,12 +14,11 @@ class TestBinarySensor(unittest.TestCase):
|
||||
sensor = binary_sensor.BinarySensorDevice()
|
||||
assert STATE_OFF == sensor.state
|
||||
with mock.patch(
|
||||
"homeassistant.components.binary_sensor." "BinarySensorDevice.is_on",
|
||||
"homeassistant.components.binary_sensor.BinarySensorDevice.is_on",
|
||||
new=False,
|
||||
):
|
||||
assert STATE_OFF == binary_sensor.BinarySensorDevice().state
|
||||
with mock.patch(
|
||||
"homeassistant.components.binary_sensor." "BinarySensorDevice.is_on",
|
||||
new=True,
|
||||
"homeassistant.components.binary_sensor.BinarySensorDevice.is_on", new=True,
|
||||
):
|
||||
assert STATE_ON == binary_sensor.BinarySensorDevice().state
|
||||
@@ -12,7 +12,7 @@ EPSILON_DELTA = 0.0000000001
|
||||
|
||||
def radar_map_url(dim: int = 512) -> str:
|
||||
"""Build map url, defaulting to 512 wide (as in component)."""
|
||||
return ("https://api.buienradar.nl/" "image/1.0/RadarMapNL?w={dim}&h={dim}").format(
|
||||
return ("https://api.buienradar.nl/image/1.0/RadarMapNL?w={dim}&h={dim}").format(
|
||||
dim=dim
|
||||
)
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class TestGetImage:
|
||||
def test_get_image_without_exists_camera(self):
|
||||
"""Try to get image without exists camera."""
|
||||
with patch(
|
||||
"homeassistant.helpers.entity_component.EntityComponent." "get_entity",
|
||||
"homeassistant.helpers.entity_component.EntityComponent.get_entity",
|
||||
return_value=None,
|
||||
), pytest.raises(HomeAssistantError):
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
|
||||
@@ -321,7 +321,7 @@ async def test_websocket_status(
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch.dict(
|
||||
"homeassistant.components.google_assistant.const." "DOMAIN_TO_GOOGLE_TYPES",
|
||||
"homeassistant.components.google_assistant.const.DOMAIN_TO_GOOGLE_TYPES",
|
||||
{"light": None},
|
||||
clear=True,
|
||||
), patch.dict(
|
||||
@@ -683,7 +683,7 @@ async def test_list_google_entities(hass, hass_ws_client, setup_api, mock_cloud_
|
||||
hass, MockConfig(should_expose=lambda *_: False), State("light.kitchen", "on")
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.google_assistant.helpers" ".async_get_entities",
|
||||
"homeassistant.components.google_assistant.helpers.async_get_entities",
|
||||
return_value=[entity],
|
||||
):
|
||||
await client.send_json({"id": 5, "type": "cloud/google_assistant/entities"})
|
||||
@@ -779,7 +779,7 @@ async def test_list_alexa_entities(hass, hass_ws_client, setup_api, mock_cloud_l
|
||||
hass, MagicMock(entity_config={}), State("light.kitchen", "on")
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.alexa.entities" ".async_get_entities",
|
||||
"homeassistant.components.alexa.entities.async_get_entities",
|
||||
return_value=[entity],
|
||||
):
|
||||
await client.send_json({"id": 5, "type": "cloud/alexa/entities"})
|
||||
|
||||
@@ -209,7 +209,7 @@ class TestDemoMediaPlayer(unittest.TestCase):
|
||||
assert "some_id" == state.attributes.get("media_content_id")
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.demo.media_player.DemoYoutubePlayer." "media_seek",
|
||||
"homeassistant.components.demo.media_player.DemoYoutubePlayer.media_seek",
|
||||
autospec=True,
|
||||
)
|
||||
def test_seek(self, mock_seek):
|
||||
|
||||
@@ -77,7 +77,7 @@ async def test_reading_broken_yaml_config(hass):
|
||||
"badkey.yaml": "@:\n name: Device",
|
||||
"noname.yaml": "my_device:\n",
|
||||
"allok.yaml": "My Device:\n name: Device",
|
||||
"oneok.yaml": ("My Device!:\n name: Device\n" "bad_device:\n nme: Device"),
|
||||
"oneok.yaml": ("My Device!:\n name: Device\nbad_device:\n nme: Device"),
|
||||
}
|
||||
args = {"hass": hass, "consider_home": timedelta(seconds=60)}
|
||||
with patch_yaml_files(files):
|
||||
@@ -341,7 +341,7 @@ async def test_group_all_devices(hass, mock_device_tracker_conf):
|
||||
assert (entity_id,) == state.attributes.get(ATTR_ENTITY_ID)
|
||||
|
||||
|
||||
@patch("homeassistant.components.device_tracker.legacy." "DeviceTracker.async_see")
|
||||
@patch("homeassistant.components.device_tracker.legacy.DeviceTracker.async_see")
|
||||
async def test_see_service(mock_see, hass):
|
||||
"""Test the see service with a unicode dev_id and NO MAC."""
|
||||
with assert_setup_component(1, device_tracker.DOMAIN):
|
||||
|
||||
@@ -56,7 +56,7 @@ def hass_hue(loop, hass):
|
||||
)
|
||||
)
|
||||
|
||||
with patch("homeassistant.components" ".emulated_hue.UPNPResponderThread"):
|
||||
with patch("homeassistant.components.emulated_hue.UPNPResponderThread"):
|
||||
loop.run_until_complete(
|
||||
setup.async_setup_component(
|
||||
hass,
|
||||
|
||||
@@ -14,7 +14,7 @@ def test_config_google_home_entity_id_to_number():
|
||||
"homeassistant.components.emulated_hue.load_json",
|
||||
return_value={"1": "light.test2"},
|
||||
) as json_loader:
|
||||
with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver:
|
||||
with patch("homeassistant.components.emulated_hue.save_json") as json_saver:
|
||||
number = conf.entity_id_to_number("light.test")
|
||||
assert number == "2"
|
||||
|
||||
@@ -48,7 +48,7 @@ def test_config_google_home_entity_id_to_number_altered():
|
||||
"homeassistant.components.emulated_hue.load_json",
|
||||
return_value={"21": "light.test2"},
|
||||
) as json_loader:
|
||||
with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver:
|
||||
with patch("homeassistant.components.emulated_hue.save_json") as json_saver:
|
||||
number = conf.entity_id_to_number("light.test")
|
||||
assert number == "22"
|
||||
assert json_saver.call_count == 1
|
||||
@@ -80,7 +80,7 @@ def test_config_google_home_entity_id_to_number_empty():
|
||||
with patch(
|
||||
"homeassistant.components.emulated_hue.load_json", return_value={}
|
||||
) as json_loader:
|
||||
with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver:
|
||||
with patch("homeassistant.components.emulated_hue.save_json") as json_saver:
|
||||
number = conf.entity_id_to_number("light.test")
|
||||
assert number == "1"
|
||||
assert json_saver.call_count == 1
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestEmulatedHue(unittest.TestCase):
|
||||
hass, http.DOMAIN, {http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_SERVER_PORT}}
|
||||
)
|
||||
|
||||
with patch("homeassistant.components" ".emulated_hue.UPNPResponderThread"):
|
||||
with patch("homeassistant.components.emulated_hue.UPNPResponderThread"):
|
||||
setup.setup_component(
|
||||
hass,
|
||||
emulated_hue.DOMAIN,
|
||||
|
||||
@@ -81,7 +81,7 @@ VALID_CONFIG = {
|
||||
def mock_healthybox():
|
||||
"""Mock fb.check_box_health."""
|
||||
check_box_health = (
|
||||
"homeassistant.components.facebox.image_processing." "check_box_health"
|
||||
"homeassistant.components.facebox.image_processing.check_box_health"
|
||||
)
|
||||
with patch(check_box_health, return_value=MOCK_BOX_ID) as _mock_healthybox:
|
||||
yield _mock_healthybox
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestFeedreaderComponent(unittest.TestCase):
|
||||
def test_setup_one_feed(self):
|
||||
"""Test the general setup of this component."""
|
||||
with patch(
|
||||
"homeassistant.components.feedreader." "track_time_interval"
|
||||
"homeassistant.components.feedreader.track_time_interval"
|
||||
) as track_method:
|
||||
assert setup_component(self.hass, feedreader.DOMAIN, VALID_CONFIG_1)
|
||||
track_method.assert_called_once_with(
|
||||
@@ -60,7 +60,7 @@ class TestFeedreaderComponent(unittest.TestCase):
|
||||
def test_setup_scan_interval(self):
|
||||
"""Test the setup of this component with scan interval."""
|
||||
with patch(
|
||||
"homeassistant.components.feedreader." "track_time_interval"
|
||||
"homeassistant.components.feedreader.track_time_interval"
|
||||
) as track_method:
|
||||
assert setup_component(self.hass, feedreader.DOMAIN, VALID_CONFIG_2)
|
||||
track_method.assert_called_once_with(
|
||||
@@ -88,7 +88,7 @@ class TestFeedreaderComponent(unittest.TestCase):
|
||||
data_file = self.hass.config.path("{}.pickle".format(feedreader.DOMAIN))
|
||||
storage = StoredData(data_file)
|
||||
with patch(
|
||||
"homeassistant.components.feedreader." "track_time_interval"
|
||||
"homeassistant.components.feedreader.track_time_interval"
|
||||
) as track_method:
|
||||
manager = FeedManager(
|
||||
feed_data, DEFAULT_SCAN_INTERVAL, max_entries, self.hass, storage
|
||||
@@ -131,7 +131,7 @@ class TestFeedreaderComponent(unittest.TestCase):
|
||||
# Must patch 'get_timestamp' method because the timestamp is stored
|
||||
# with the URL which in these tests is the raw XML data.
|
||||
with patch(
|
||||
"homeassistant.components.feedreader.StoredData." "get_timestamp",
|
||||
"homeassistant.components.feedreader.StoredData.get_timestamp",
|
||||
return_value=time.struct_time((2018, 4, 30, 5, 10, 0, 0, 120, 0)),
|
||||
):
|
||||
manager2, events2 = self.setup_manager(feed_data2)
|
||||
@@ -139,7 +139,7 @@ class TestFeedreaderComponent(unittest.TestCase):
|
||||
# 3. Run
|
||||
feed_data3 = load_fixture("feedreader1.xml")
|
||||
with patch(
|
||||
"homeassistant.components.feedreader.StoredData." "get_timestamp",
|
||||
"homeassistant.components.feedreader.StoredData.get_timestamp",
|
||||
return_value=time.struct_time((2018, 4, 30, 5, 11, 0, 0, 120, 0)),
|
||||
):
|
||||
manager3, events3 = self.setup_manager(feed_data3)
|
||||
|
||||
@@ -117,11 +117,11 @@ class TestFilterSensor(unittest.TestCase):
|
||||
}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.history." "state_changes_during_period",
|
||||
"homeassistant.components.history.state_changes_during_period",
|
||||
return_value=fake_states,
|
||||
):
|
||||
with patch(
|
||||
"homeassistant.components.history." "get_last_state_changes",
|
||||
"homeassistant.components.history.get_last_state_changes",
|
||||
return_value=fake_states,
|
||||
):
|
||||
with assert_setup_component(1, "sensor"):
|
||||
@@ -165,11 +165,11 @@ class TestFilterSensor(unittest.TestCase):
|
||||
]
|
||||
}
|
||||
with patch(
|
||||
"homeassistant.components.history." "state_changes_during_period",
|
||||
"homeassistant.components.history.state_changes_during_period",
|
||||
return_value=fake_states,
|
||||
):
|
||||
with patch(
|
||||
"homeassistant.components.history." "get_last_state_changes",
|
||||
"homeassistant.components.history.get_last_state_changes",
|
||||
return_value=fake_states,
|
||||
):
|
||||
with assert_setup_component(1, "sensor"):
|
||||
|
||||
@@ -20,7 +20,7 @@ def hassio_env():
|
||||
"homeassistant.components.hassio.HassIO.is_connected",
|
||||
Mock(return_value=mock_coro({"result": "ok", "data": {}})),
|
||||
), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}), patch(
|
||||
"homeassistant.components.hassio.HassIO." "get_homeassistant_info",
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
Mock(side_effect=HassioAPIError()),
|
||||
):
|
||||
yield
|
||||
|
||||
@@ -40,7 +40,7 @@ async def test_hassio_discovery_startup(hass, aioclient_mock, hassio_client):
|
||||
assert aioclient_mock.call_count == 0
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio",
|
||||
"homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio",
|
||||
Mock(return_value=mock_coro({"type": "abort"})),
|
||||
) as mock_mqtt:
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
|
||||
@@ -93,10 +93,10 @@ async def test_hassio_discovery_startup_done(hass, aioclient_mock, hassio_client
|
||||
"homeassistant.components.hassio.HassIO.update_hass_api",
|
||||
Mock(return_value=mock_coro({"result": "ok"})),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.HassIO." "get_homeassistant_info",
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
Mock(side_effect=HassioAPIError()),
|
||||
), patch(
|
||||
"homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio",
|
||||
"homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio",
|
||||
Mock(return_value=mock_coro({"type": "abort"})),
|
||||
) as mock_mqtt:
|
||||
await hass.async_start()
|
||||
@@ -143,7 +143,7 @@ async def test_hassio_discovery_webhook(hass, aioclient_mock, hassio_client):
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio",
|
||||
"homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio",
|
||||
Mock(return_value=mock_coro({"type": "abort"})),
|
||||
) as mock_mqtt:
|
||||
resp = await hassio_client.post(
|
||||
|
||||
@@ -387,7 +387,7 @@ async def test_public_transport(hass, requests_mock_credentials_check):
|
||||
assert sensor.attributes.get(ATTR_DURATION) == 89.16666666666667
|
||||
assert sensor.attributes.get(ATTR_DISTANCE) == 22.325
|
||||
assert sensor.attributes.get(ATTR_ROUTE) == (
|
||||
"332 - Palmer/Schiller; 332 - Cargo Rd./Delta Cargo; " "332 - Palmer/Schiller"
|
||||
"332 - Palmer/Schiller; 332 - Cargo Rd./Delta Cargo; 332 - Palmer/Schiller"
|
||||
)
|
||||
assert sensor.attributes.get(CONF_UNIT_SYSTEM) == "metric"
|
||||
assert sensor.attributes.get(ATTR_DURATION_IN_TRAFFIC) == 89.16666666666667
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestHistoryStatsSensor(unittest.TestCase):
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
@patch(
|
||||
"homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable",
|
||||
"homeassistant.helpers.template.TemplateEnvironment.is_safe_callable",
|
||||
return_value=True,
|
||||
)
|
||||
def test_period_parsing(self, mock):
|
||||
@@ -58,7 +58,7 @@ class TestHistoryStatsSensor(unittest.TestCase):
|
||||
now = datetime(2019, 1, 1, 23, 30, 0, tzinfo=pytz.utc)
|
||||
with patch("homeassistant.util.dt.now", return_value=now):
|
||||
today = Template(
|
||||
"{{ now().replace(hour=0).replace(minute=0)" ".replace(second=0) }}",
|
||||
"{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}",
|
||||
self.hass,
|
||||
)
|
||||
duration = timedelta(hours=2, minutes=1)
|
||||
@@ -137,7 +137,7 @@ class TestHistoryStatsSensor(unittest.TestCase):
|
||||
assert sensor4._type == "ratio"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.history." "state_changes_during_period",
|
||||
"homeassistant.components.history.state_changes_during_period",
|
||||
return_value=fake_states,
|
||||
):
|
||||
with patch("homeassistant.components.history.get_state", return_value=None):
|
||||
|
||||
@@ -97,7 +97,7 @@ async def test_home_accessory(hass, hk_driver):
|
||||
hass.states.async_set(entity_id, "on")
|
||||
await hass.async_block_till_done()
|
||||
with patch(
|
||||
"homeassistant.components.homekit.accessories." "HomeAccessory.update_state"
|
||||
"homeassistant.components.homekit.accessories.HomeAccessory.update_state"
|
||||
) as mock_update_state:
|
||||
await hass.async_add_job(acc.run)
|
||||
await hass.async_block_till_done()
|
||||
@@ -343,7 +343,7 @@ def test_home_driver():
|
||||
|
||||
# pair
|
||||
with patch("pyhap.accessory_driver.AccessoryDriver.pair") as mock_pair, patch(
|
||||
"homeassistant.components.homekit.accessories." "dismiss_setup_message"
|
||||
"homeassistant.components.homekit.accessories.dismiss_setup_message"
|
||||
) as mock_dissmiss_msg:
|
||||
driver.pair("client_uuid", "client_public")
|
||||
|
||||
@@ -352,7 +352,7 @@ def test_home_driver():
|
||||
|
||||
# unpair
|
||||
with patch("pyhap.accessory_driver.AccessoryDriver.unpair") as mock_unpair, patch(
|
||||
"homeassistant.components.homekit.accessories." "show_setup_message"
|
||||
"homeassistant.components.homekit.accessories.show_setup_message"
|
||||
) as mock_show_msg:
|
||||
driver.unpair("client_uuid")
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
"""A test class for Honeywell themostats."""
|
||||
|
||||
@mock.patch("somecomfort.SomeComfort")
|
||||
@mock.patch("homeassistant.components.honeywell." "climate.HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def test_setup_us(self, mock_ht, mock_sc):
|
||||
"""Test for the US setup."""
|
||||
config = {
|
||||
@@ -98,7 +98,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
assert not add_entities.called
|
||||
|
||||
@mock.patch("somecomfort.SomeComfort")
|
||||
@mock.patch("homeassistant.components.honeywell." "climate.HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def _test_us_filtered_devices(self, mock_ht, mock_sc, loc=None, dev=None):
|
||||
"""Test for US filtered thermostats."""
|
||||
config = {
|
||||
@@ -157,7 +157,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
assert [mock.sentinel.loc2dev1] == devices
|
||||
|
||||
@mock.patch("evohomeclient.EvohomeClient")
|
||||
@mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def test_eu_setup_full_config(self, mock_round, mock_evo):
|
||||
"""Test the EU setup with complete configuration."""
|
||||
config = {
|
||||
@@ -184,7 +184,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
assert 2 == add_entities.call_count
|
||||
|
||||
@mock.patch("evohomeclient.EvohomeClient")
|
||||
@mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def test_eu_setup_partial_config(self, mock_round, mock_evo):
|
||||
"""Test the EU setup with partial configuration."""
|
||||
config = {
|
||||
@@ -206,7 +206,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
)
|
||||
|
||||
@mock.patch("evohomeclient.EvohomeClient")
|
||||
@mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def test_eu_setup_bad_temp(self, mock_round, mock_evo):
|
||||
"""Test the EU setup with invalid temperature."""
|
||||
config = {
|
||||
@@ -219,7 +219,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.PLATFORM_SCHEMA(config)
|
||||
|
||||
@mock.patch("evohomeclient.EvohomeClient")
|
||||
@mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat")
|
||||
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
|
||||
def test_eu_setup_error(self, mock_round, mock_evo):
|
||||
"""Test the EU setup with errors."""
|
||||
config = {
|
||||
|
||||
@@ -94,7 +94,7 @@ async def test_setup(hass):
|
||||
# Patching 'utcnow' to gain more control over the timed update.
|
||||
utcnow = dt_util.utcnow()
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=utcnow), patch(
|
||||
"georss_ign_sismologia_client." "IgnSismologiaFeed"
|
||||
"georss_ign_sismologia_client.IgnSismologiaFeed"
|
||||
) as mock_feed:
|
||||
mock_feed.return_value.update.return_value = (
|
||||
"OK",
|
||||
@@ -199,7 +199,7 @@ async def test_setup_with_custom_location(hass):
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 20.5, (38.1, -3.1))
|
||||
|
||||
with patch("georss_ign_sismologia_client." "IgnSismologiaFeed") as mock_feed:
|
||||
with patch("georss_ign_sismologia_client.IgnSismologiaFeed") as mock_feed:
|
||||
mock_feed.return_value.update.return_value = "OK", [mock_entry_1]
|
||||
|
||||
with assert_setup_component(1, geo_location.DOMAIN):
|
||||
|
||||
@@ -175,7 +175,7 @@ async def test_islamic_prayer_times_sensor_update(hass):
|
||||
future = midnight_dt + timedelta(days=1, minutes=1)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.islamic_prayer_times.sensor" ".dt_util.utcnow",
|
||||
"homeassistant.components.islamic_prayer_times.sensor.dt_util.utcnow",
|
||||
return_value=future,
|
||||
):
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class TestLogentries(unittest.TestCase):
|
||||
}
|
||||
]
|
||||
payload = {
|
||||
"host": "https://webhook.logentries.com/noformat/" "logs/token",
|
||||
"host": "https://webhook.logentries.com/noformat/logs/token",
|
||||
"event": body,
|
||||
}
|
||||
self.handler_method(event)
|
||||
|
||||
@@ -38,7 +38,7 @@ async def test_get_messages_from_mailbox(mock_http_client):
|
||||
async def test_get_media_from_mailbox(mock_http_client):
|
||||
"""Get audio from mailbox."""
|
||||
mp3sha = "3f67c4ea33b37d1710f772a26dd3fb43bb159d50"
|
||||
msgtxt = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
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)
|
||||
@@ -50,8 +50,8 @@ async def test_get_media_from_mailbox(mock_http_client):
|
||||
|
||||
async def test_delete_from_mailbox(mock_http_client):
|
||||
"""Get audio from mailbox."""
|
||||
msgtxt1 = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
msgtxt2 = "Message 3. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
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()
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ async def test_arm_home_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -252,7 +252,7 @@ async def test_arm_away_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -367,7 +367,7 @@ async def test_arm_night_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -432,7 +432,7 @@ async def test_trigger_no_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=60)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -474,7 +474,7 @@ async def test_trigger_with_delay(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -563,7 +563,7 @@ async def test_trigger_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -574,7 +574,7 @@ async def test_trigger_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -618,7 +618,7 @@ async def test_trigger_with_unused_specific_delay(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -662,7 +662,7 @@ async def test_trigger_with_specific_delay(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -706,7 +706,7 @@ async def test_trigger_with_pending_and_delay(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -718,7 +718,7 @@ async def test_trigger_with_pending_and_delay(hass):
|
||||
|
||||
future += timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -763,7 +763,7 @@ async def test_trigger_with_pending_and_specific_delay(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -775,7 +775,7 @@ async def test_trigger_with_pending_and_specific_delay(hass):
|
||||
|
||||
future += timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -808,7 +808,7 @@ async def test_armed_home_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -840,7 +840,7 @@ async def test_armed_away_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -872,7 +872,7 @@ async def test_armed_night_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -906,7 +906,7 @@ async def test_trigger_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -916,7 +916,7 @@ async def test_trigger_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -951,7 +951,7 @@ async def test_trigger_with_disarm_after_trigger(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1013,7 +1013,7 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1048,7 +1048,7 @@ async def test_trigger_with_specific_trigger_time(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1087,7 +1087,7 @@ async def test_trigger_with_no_disarm_after_trigger(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1126,7 +1126,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1140,7 +1140,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1178,7 +1178,7 @@ async def test_disarm_while_pending_trigger(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1217,7 +1217,7 @@ async def test_disarm_during_trigger_with_invalid_code(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=5)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1342,7 +1342,7 @@ async def test_arm_custom_bypass_with_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1400,7 +1400,7 @@ async def test_armed_custom_bypass_with_specific_pending(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=2)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1448,7 +1448,7 @@ async def test_arm_away_after_disabled_disarmed(hass):
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -1466,7 +1466,7 @@ async def test_arm_away_after_disabled_disarmed(hass):
|
||||
|
||||
future += timedelta(seconds=1)
|
||||
with patch(
|
||||
("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"),
|
||||
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
|
||||
return_value=future,
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestMicrosoftFaceSetup:
|
||||
self.hass.stop()
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_component(self, mock_update):
|
||||
@@ -105,7 +105,7 @@ class TestMicrosoftFaceSetup:
|
||||
setup_component(self.hass, mf.DOMAIN, self.config)
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_component_wrong_api_key(self, mock_update):
|
||||
@@ -114,7 +114,7 @@ class TestMicrosoftFaceSetup:
|
||||
setup_component(self.hass, mf.DOMAIN, {mf.DOMAIN: {}})
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_component_test_service(self, mock_update):
|
||||
@@ -170,7 +170,7 @@ class TestMicrosoftFaceSetup:
|
||||
)
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_service_groups(self, mock_update, aioclient_mock):
|
||||
@@ -257,7 +257,7 @@ class TestMicrosoftFaceSetup:
|
||||
assert "Hans" not in entity_group1.attributes
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_service_train(self, mock_update, aioclient_mock):
|
||||
@@ -317,7 +317,7 @@ class TestMicrosoftFaceSetup:
|
||||
assert aioclient_mock.mock_calls[3][2] == b"Test"
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_service_status_400(self, mock_update, aioclient_mock):
|
||||
@@ -339,7 +339,7 @@ class TestMicrosoftFaceSetup:
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_service_status_timeout(self, mock_update, aioclient_mock):
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestMicrosoftFaceDetectSetup:
|
||||
self.hass.stop()
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_platform(self, store_mock):
|
||||
@@ -49,7 +49,7 @@ class TestMicrosoftFaceDetectSetup:
|
||||
assert self.hass.states.get("image_processing.microsoftface_demo_camera")
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_platform_name(self, store_mock):
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestMicrosoftFaceIdentifySetup:
|
||||
self.hass.stop()
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_platform(self, store_mock):
|
||||
@@ -49,7 +49,7 @@ class TestMicrosoftFaceIdentifySetup:
|
||||
assert self.hass.states.get("image_processing.microsoftface_demo_camera")
|
||||
|
||||
@patch(
|
||||
"homeassistant.components.microsoft_face." "MicrosoftFace.update_store",
|
||||
"homeassistant.components.microsoft_face.MicrosoftFace.update_store",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
def test_setup_platform_name(self, store_mock):
|
||||
|
||||
@@ -78,7 +78,7 @@ async def expires_helper(hass, mqtt_mock, caplog):
|
||||
"""Run the basic expiry code."""
|
||||
|
||||
now = datetime(2017, 1, 1, 1, tzinfo=dt_util.UTC)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now):
|
||||
async_fire_time_changed(hass, now)
|
||||
async_fire_mqtt_message(hass, "test-topic", "ON")
|
||||
await hass.async_block_till_done()
|
||||
@@ -97,7 +97,7 @@ async def expires_helper(hass, mqtt_mock, caplog):
|
||||
assert state.state == STATE_ON
|
||||
|
||||
# Next message resets timer
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now):
|
||||
async_fire_time_changed(hass, now)
|
||||
async_fire_mqtt_message(hass, "test-topic", "OFF")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -113,7 +113,7 @@ async def test_set_operation_bad_attr_and_state(hass, mqtt_mock, caplog):
|
||||
assert state.state == "off"
|
||||
with pytest.raises(vol.Invalid) as excinfo:
|
||||
await common.async_set_hvac_mode(hass, None, ENTITY_CLIMATE)
|
||||
assert ("value is not allowed for dictionary value @ " "data['hvac_mode']") in str(
|
||||
assert ("value is not allowed for dictionary value @ data['hvac_mode']") in str(
|
||||
excinfo.value
|
||||
)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
|
||||
@@ -27,7 +27,7 @@ async def test_ensure_device_tracker_platform_validation(hass):
|
||||
assert "qos" in config
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.mqtt.device_tracker." "async_setup_scanner",
|
||||
"homeassistant.components.mqtt.device_tracker.async_setup_scanner",
|
||||
autospec=True,
|
||||
side_effect=mock_setup_scanner,
|
||||
) as mock_sp:
|
||||
|
||||
@@ -179,9 +179,7 @@ async def test_discovery_incl_nodeid(hass, mqtt_mock, caplog):
|
||||
await async_start(hass, "homeassistant", {}, entry)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"homeassistant/binary_sensor/my_node_id/bla" "/config",
|
||||
'{ "name": "Beer" }',
|
||||
hass, "homeassistant/binary_sensor/my_node_id/bla/config", '{ "name": "Beer" }',
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -212,7 +210,7 @@ async def test_non_duplicate_discovery(hass, mqtt_mock, caplog):
|
||||
assert state is not None
|
||||
assert state.name == "Beer"
|
||||
assert state_duplicate is None
|
||||
assert "Component has already been discovered: " "binary_sensor bla" in caplog.text
|
||||
assert "Component has already been discovered: binary_sensor bla" in caplog.text
|
||||
|
||||
|
||||
async def test_discovery_expansion(hass, mqtt_mock, caplog):
|
||||
@@ -424,7 +422,7 @@ async def test_complex_discovery_topic_prefix(hass, mqtt_mock, caplog):
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
("my_home/homeassistant/register" "/binary_sensor/node1/object1/config"),
|
||||
("my_home/homeassistant/register/binary_sensor/node1/object1/config"),
|
||||
'{ "name": "Beer" }',
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -555,7 +555,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state",
|
||||
"homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state",
|
||||
return_value=mock_coro(fake_state),
|
||||
):
|
||||
with assert_setup_component(1, light.DOMAIN):
|
||||
|
||||
@@ -299,7 +299,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state",
|
||||
"homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state",
|
||||
return_value=mock_coro(fake_state),
|
||||
):
|
||||
assert await async_setup_component(
|
||||
|
||||
@@ -261,7 +261,7 @@ async def test_optimistic(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state",
|
||||
"homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state",
|
||||
return_value=mock_coro(fake_state),
|
||||
):
|
||||
with assert_setup_component(1, light.DOMAIN):
|
||||
|
||||
@@ -63,7 +63,7 @@ async def test_setting_sensor_value_expires(hass, mqtt_mock, caplog):
|
||||
assert state.state == "unknown"
|
||||
|
||||
now = datetime(2017, 1, 1, 1, tzinfo=dt_util.UTC)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now):
|
||||
async_fire_time_changed(hass, now)
|
||||
async_fire_mqtt_message(hass, "test-topic", "100")
|
||||
await hass.async_block_till_done()
|
||||
@@ -82,7 +82,7 @@ async def test_setting_sensor_value_expires(hass, mqtt_mock, caplog):
|
||||
assert state.state == "100"
|
||||
|
||||
# Next message resets timer
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now):
|
||||
async_fire_time_changed(hass, now)
|
||||
async_fire_mqtt_message(hass, "test-topic", "101")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -69,7 +69,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mock_publish):
|
||||
fake_state = ha.State("switch.test", "on")
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state",
|
||||
"homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state",
|
||||
return_value=mock_coro(fake_state),
|
||||
):
|
||||
assert await async_setup_component(
|
||||
|
||||
@@ -46,7 +46,7 @@ async def test_ensure_device_tracker_platform_validation(hass):
|
||||
assert "qos" in config
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.mqtt_json.device_tracker." "async_setup_scanner",
|
||||
"homeassistant.components.mqtt_json.device_tracker.async_setup_scanner",
|
||||
autospec=True,
|
||||
side_effect=mock_setup_scanner,
|
||||
) as mock_sp:
|
||||
|
||||
@@ -126,7 +126,7 @@ async def test_user_not_supports_encryption(hass, not_supports_encryption):
|
||||
async def test_unload(hass):
|
||||
"""Test unloading a config flow."""
|
||||
with patch(
|
||||
"homeassistant.config_entries.ConfigEntries" ".async_forward_entry_setup"
|
||||
"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup"
|
||||
) as mock_forward:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "import"}, data={}
|
||||
@@ -140,7 +140,7 @@ async def test_unload(hass):
|
||||
assert entry.data["webhook_id"] in hass.data["webhook"]
|
||||
|
||||
with patch(
|
||||
"homeassistant.config_entries.ConfigEntries" ".async_forward_entry_unload",
|
||||
"homeassistant.config_entries.ConfigEntries.async_forward_entry_unload",
|
||||
return_value=mock_coro(),
|
||||
) as mock_unload:
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
||||
@@ -1300,7 +1300,7 @@ async def test_single_waypoint_import(hass, context):
|
||||
async def test_not_implemented_message(hass, context):
|
||||
"""Handle not implemented message type."""
|
||||
patch_handler = patch(
|
||||
"homeassistant.components.owntracks." "messages.async_handle_not_impl_msg",
|
||||
"homeassistant.components.owntracks.messages.async_handle_not_impl_msg",
|
||||
return_value=mock_coro(False),
|
||||
)
|
||||
patch_handler.start()
|
||||
@@ -1311,7 +1311,7 @@ async def test_not_implemented_message(hass, context):
|
||||
async def test_unsupported_message(hass, context):
|
||||
"""Handle not implemented message type."""
|
||||
patch_handler = patch(
|
||||
"homeassistant.components.owntracks." "messages.async_handle_unsupported_msg",
|
||||
"homeassistant.components.owntracks.messages.async_handle_unsupported_msg",
|
||||
return_value=mock_coro(False),
|
||||
)
|
||||
patch_handler.start()
|
||||
@@ -1396,7 +1396,7 @@ def config_context(hass, setup_comp):
|
||||
patch_load.start()
|
||||
|
||||
patch_save = patch(
|
||||
"homeassistant.components.device_tracker." "DeviceTracker.async_update_config"
|
||||
"homeassistant.components.device_tracker.DeviceTracker.async_update_config"
|
||||
)
|
||||
patch_save.start()
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ async def test_setup(hass):
|
||||
# Patching 'utcnow' to gain more control over the timed update.
|
||||
utcnow = dt_util.utcnow()
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=utcnow), patch(
|
||||
"georss_qld_bushfire_alert_client." "QldBushfireAlertFeed"
|
||||
"georss_qld_bushfire_alert_client.QldBushfireAlertFeed"
|
||||
) as mock_feed:
|
||||
mock_feed.return_value.update.return_value = (
|
||||
"OK",
|
||||
@@ -193,7 +193,7 @@ async def test_setup_with_custom_location(hass):
|
||||
"1234", "Title 1", 20.5, (38.1, -3.1), category="Category 1"
|
||||
)
|
||||
|
||||
with patch("georss_qld_bushfire_alert_client." "QldBushfireAlertFeed") as mock_feed:
|
||||
with patch("georss_qld_bushfire_alert_client.QldBushfireAlertFeed") as mock_feed:
|
||||
mock_feed.return_value.update.return_value = "OK", [mock_entry_1]
|
||||
|
||||
with assert_setup_component(1, geo_location.DOMAIN):
|
||||
|
||||
@@ -182,7 +182,7 @@ def mocked_requests_get(*args, **kwargs):
|
||||
"sqliteVersion": "3.16.2",
|
||||
"urlBase": "",
|
||||
"runtimeVersion": (
|
||||
"4.6.1 " "(Stable 4.6.1.3/abb06f1 " "Mon Oct 3 07:57:59 UTC 2016)"
|
||||
"4.6.1 (Stable 4.6.1.3/abb06f1 Mon Oct 3 07:57:59 UTC 2016)"
|
||||
),
|
||||
},
|
||||
200,
|
||||
|
||||
@@ -126,7 +126,7 @@ async def test_off_delay(hass, monkeypatch):
|
||||
now = dt_util.utcnow()
|
||||
# fake time and turn on sensor
|
||||
future = now + timedelta(seconds=0)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
|
||||
async_fire_time_changed(hass, future)
|
||||
event_callback(on_event)
|
||||
await hass.async_block_till_done()
|
||||
@@ -136,7 +136,7 @@ async def test_off_delay(hass, monkeypatch):
|
||||
|
||||
# fake time and turn on sensor again
|
||||
future = now + timedelta(seconds=15)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
|
||||
async_fire_time_changed(hass, future)
|
||||
event_callback(on_event)
|
||||
await hass.async_block_till_done()
|
||||
@@ -146,7 +146,7 @@ async def test_off_delay(hass, monkeypatch):
|
||||
|
||||
# fake time and verify sensor still on (de-bounce)
|
||||
future = now + timedelta(seconds=35)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("binary_sensor.test2")
|
||||
@@ -155,7 +155,7 @@ async def test_off_delay(hass, monkeypatch):
|
||||
|
||||
# fake time and verify sensor is off
|
||||
future = now + timedelta(seconds=45)
|
||||
with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future):
|
||||
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("binary_sensor.test2")
|
||||
|
||||
@@ -111,7 +111,7 @@ class TestShellCommand(unittest.TestCase):
|
||||
shell_command.DOMAIN,
|
||||
{
|
||||
shell_command.DOMAIN: {
|
||||
"test_service": ("ls /bin {{ states.sensor" ".test_state.state }}")
|
||||
"test_service": ("ls /bin {{ states.sensor.test_state.state }}")
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ from homeassistant.setup import async_setup_component
|
||||
def mock_shopping_list_io():
|
||||
"""Stub out the persistence."""
|
||||
with patch("homeassistant.components.shopping_list.ShoppingData.save"), patch(
|
||||
"homeassistant.components.shopping_list." "ShoppingData.async_load"
|
||||
"homeassistant.components.shopping_list.ShoppingData.async_load"
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ async def test_capped_setup(hass, aioclient_mock):
|
||||
"</usage>"
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"https://www.start.ca/support/usage/api?key=" "NOTAKEY", text=result
|
||||
"https://www.start.ca/support/usage/api?key=NOTAKEY", text=result
|
||||
)
|
||||
|
||||
await async_setup_component(hass, "sensor", {"sensor": config})
|
||||
@@ -140,7 +140,7 @@ async def test_unlimited_setup(hass, aioclient_mock):
|
||||
"</usage>"
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"https://www.start.ca/support/usage/api?key=" "NOTAKEY", text=result
|
||||
"https://www.start.ca/support/usage/api?key=NOTAKEY", text=result
|
||||
)
|
||||
|
||||
await async_setup_component(hass, "sensor", {"sensor": config})
|
||||
@@ -196,9 +196,7 @@ async def test_unlimited_setup(hass, aioclient_mock):
|
||||
|
||||
async def test_bad_return_code(hass, aioclient_mock):
|
||||
"""Test handling a return code that isn't HTTP OK."""
|
||||
aioclient_mock.get(
|
||||
"https://www.start.ca/support/usage/api?key=" "NOTAKEY", status=404
|
||||
)
|
||||
aioclient_mock.get("https://www.start.ca/support/usage/api?key=NOTAKEY", status=404)
|
||||
|
||||
scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400)
|
||||
|
||||
@@ -209,7 +207,7 @@ async def test_bad_return_code(hass, aioclient_mock):
|
||||
async def test_bad_json_decode(hass, aioclient_mock):
|
||||
"""Test decoding invalid json result."""
|
||||
aioclient_mock.get(
|
||||
"https://www.start.ca/support/usage/api?key=" "NOTAKEY", text="this is not xml"
|
||||
"https://www.start.ca/support/usage/api?key=NOTAKEY", text="this is not xml"
|
||||
)
|
||||
|
||||
scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400)
|
||||
|
||||
@@ -51,7 +51,7 @@ def mock_session_response(*args, **kwargs):
|
||||
def mock_exception_logger():
|
||||
"""Mock pyunifi."""
|
||||
with mock.patch(
|
||||
"homeassistant.components.tomato.device_tracker" "._LOGGER.exception"
|
||||
"homeassistant.components.tomato.device_tracker._LOGGER.exception"
|
||||
) as mock_exception_logger:
|
||||
yield mock_exception_logger
|
||||
|
||||
@@ -312,7 +312,7 @@ def test_config_bad_credentials(hass, mock_exception_logger):
|
||||
|
||||
assert mock_exception_logger.call_count == 1
|
||||
assert mock_exception_logger.mock_calls[0] == mock.call(
|
||||
"Failed to authenticate, " "please check your username and password"
|
||||
"Failed to authenticate, please check your username and password"
|
||||
)
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ def test_bad_connection(hass, mock_exception_logger):
|
||||
tomato.get_scanner(hass, config)
|
||||
assert mock_exception_logger.call_count == 1
|
||||
assert mock_exception_logger.mock_calls[0] == mock.call(
|
||||
"Failed to connect to the router " "or invalid http_id supplied"
|
||||
"Failed to connect to the router or invalid http_id supplied"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ async def test_unload(hass, platform):
|
||||
with patch(
|
||||
"homeassistant.components.tplink.common.SmartDevice._query_helper"
|
||||
), patch(
|
||||
"homeassistant.components.tplink.{}" ".async_setup_entry".format(platform),
|
||||
"homeassistant.components.tplink.{}.async_setup_entry".format(platform),
|
||||
return_value=mock_coro(True),
|
||||
) as light_setup:
|
||||
config = {
|
||||
|
||||
@@ -8,6 +8,6 @@ import pytest
|
||||
def mock_gateway_info():
|
||||
"""Mock get_gateway_info."""
|
||||
with patch(
|
||||
"homeassistant.components.tradfri.config_flow." "get_gateway_info"
|
||||
"homeassistant.components.tradfri.config_flow.get_gateway_info"
|
||||
) as mock_gateway:
|
||||
yield mock_gateway
|
||||
@@ -13,7 +13,7 @@ from tests.common import MockConfigEntry, mock_coro
|
||||
def mock_auth():
|
||||
"""Mock authenticate."""
|
||||
with patch(
|
||||
"homeassistant.components.tradfri.config_flow." "authenticate"
|
||||
"homeassistant.components.tradfri.config_flow.authenticate"
|
||||
) as mock_auth:
|
||||
yield mock_auth
|
||||
|
||||
@@ -21,7 +21,7 @@ def mock_auth():
|
||||
@pytest.fixture
|
||||
def mock_entry_setup():
|
||||
"""Mock entry setup."""
|
||||
with patch("homeassistant.components.tradfri." "async_setup_entry") as mock_setup:
|
||||
with patch("homeassistant.components.tradfri.async_setup_entry") as mock_setup:
|
||||
mock_setup.return_value = mock_coro(True)
|
||||
yield mock_setup
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class TestTTS:
|
||||
assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3".format(
|
||||
self.hass.config.api.base_url
|
||||
)
|
||||
assert os.path.isfile(
|
||||
@@ -129,7 +129,7 @@ class TestTTS:
|
||||
assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_-_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3".format(
|
||||
self.hass.config.api.base_url
|
||||
)
|
||||
assert os.path.isfile(
|
||||
@@ -169,7 +169,7 @@ class TestTTS:
|
||||
assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_-_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3".format(
|
||||
self.hass.config.api.base_url
|
||||
)
|
||||
assert os.path.isfile(
|
||||
@@ -232,7 +232,7 @@ class TestTTS:
|
||||
assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_{}_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_{}_demo.mp3".format(
|
||||
self.hass.config.api.base_url, opt_hash
|
||||
)
|
||||
assert os.path.isfile(
|
||||
@@ -273,7 +273,7 @@ class TestTTS:
|
||||
assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_{}_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_{}_demo.mp3".format(
|
||||
self.hass.config.api.base_url, opt_hash
|
||||
)
|
||||
assert os.path.isfile(
|
||||
@@ -449,7 +449,7 @@ class TestTTS:
|
||||
self.hass.start()
|
||||
|
||||
url = (
|
||||
"{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3"
|
||||
"{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3"
|
||||
).format(self.hass.config.api.base_url)
|
||||
|
||||
req = requests.get(url)
|
||||
@@ -465,7 +465,7 @@ class TestTTS:
|
||||
self.hass.start()
|
||||
|
||||
url = (
|
||||
"{}/api/tts_proxy/265944dsk32c1b2a621be5930510bb2cd" "_en_-_demo.mp3"
|
||||
"{}/api/tts_proxy/265944dsk32c1b2a621be5930510bb2cd_en_-_demo.mp3"
|
||||
).format(self.hass.config.api.base_url)
|
||||
|
||||
req = requests.get(url)
|
||||
@@ -542,7 +542,7 @@ class TestTTS:
|
||||
setup_component(self.hass, tts.DOMAIN, config)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.demo.tts.DemoProvider." "get_tts_audio",
|
||||
"homeassistant.components.demo.tts.DemoProvider.get_tts_audio",
|
||||
return_value=(None, None),
|
||||
):
|
||||
self.hass.services.call(
|
||||
@@ -555,7 +555,7 @@ class TestTTS:
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data[
|
||||
ATTR_MEDIA_CONTENT_ID
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3".format(
|
||||
] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3".format(
|
||||
self.hass.config.api.base_url
|
||||
)
|
||||
|
||||
@@ -601,7 +601,7 @@ class TestTTS:
|
||||
self.hass.start()
|
||||
|
||||
url = (
|
||||
"{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3"
|
||||
"{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3"
|
||||
).format(self.hass.config.api.base_url)
|
||||
|
||||
req = requests.get(url)
|
||||
|
||||
@@ -44,7 +44,7 @@ async def test_auth_events(
|
||||
async def test_auth_via_msg_incorrect_pass(no_auth_websocket_client):
|
||||
"""Test authenticating."""
|
||||
with patch(
|
||||
"homeassistant.components.websocket_api.auth." "process_wrong_login",
|
||||
"homeassistant.components.websocket_api.auth.process_wrong_login",
|
||||
return_value=mock_coro(),
|
||||
) as mock_process_wrong_login:
|
||||
await no_auth_websocket_client.send_json(
|
||||
|
||||
@@ -49,11 +49,9 @@ URL = (
|
||||
"http://api.wunderground.com/api/foo/alerts/conditions/forecast/lang"
|
||||
":EN/q/32.87336,-117.22743.json"
|
||||
)
|
||||
PWS_URL = (
|
||||
"http://api.wunderground.com/api/foo/alerts/conditions/" "lang:EN/q/pws:bar.json"
|
||||
)
|
||||
PWS_URL = "http://api.wunderground.com/api/foo/alerts/conditions/lang:EN/q/pws:bar.json"
|
||||
INVALID_URL = (
|
||||
"http://api.wunderground.com/api/BOB/alerts/conditions/" "lang:foo/q/pws:bar.json"
|
||||
"http://api.wunderground.com/api/BOB/alerts/conditions/lang:foo/q/pws:bar.json"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ NOW = datetime(2016, 6, 9, 1, tzinfo=dt_util.UTC)
|
||||
async def test_default_setup(hass, aioclient_mock):
|
||||
"""Test the default setup."""
|
||||
aioclient_mock.get(
|
||||
"https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/",
|
||||
"https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/",
|
||||
text=load_fixture("yr.no.xml"),
|
||||
)
|
||||
config = {"platform": "yr", "elevation": 0}
|
||||
@@ -32,7 +32,7 @@ async def test_default_setup(hass, aioclient_mock):
|
||||
async def test_custom_setup(hass, aioclient_mock):
|
||||
"""Test a custom setup."""
|
||||
aioclient_mock.get(
|
||||
"https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/",
|
||||
"https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/",
|
||||
text=load_fixture("yr.no.xml"),
|
||||
)
|
||||
|
||||
@@ -77,7 +77,7 @@ async def test_custom_setup(hass, aioclient_mock):
|
||||
async def test_forecast_setup(hass, aioclient_mock):
|
||||
"""Test a custom setup with 24h forecast."""
|
||||
aioclient_mock.get(
|
||||
"https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/",
|
||||
"https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/",
|
||||
text=load_fixture("yr.no.xml"),
|
||||
)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ async def test_user_flow(hass):
|
||||
flow.hass = hass
|
||||
|
||||
with asynctest.patch(
|
||||
"homeassistant.components.zha.config_flow" ".check_zigpy_connection",
|
||||
"homeassistant.components.zha.config_flow.check_zigpy_connection",
|
||||
return_value=False,
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
@@ -26,7 +26,7 @@ async def test_user_flow(hass):
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
with asynctest.patch(
|
||||
"homeassistant.components.zha.config_flow" ".check_zigpy_connection",
|
||||
"homeassistant.components.zha.config_flow.check_zigpy_connection",
|
||||
return_value=True,
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ def verify_cleanup():
|
||||
for inst in INSTANCES:
|
||||
inst.stop()
|
||||
pytest.exit(
|
||||
"Detected non stopped instances " "({}), aborting test run".format(count)
|
||||
"Detected non stopped instances ({}), aborting test run".format(count)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ BASE_CONFIG = (
|
||||
"\n\n"
|
||||
)
|
||||
|
||||
BAD_CORE_CONFIG = "homeassistant:\n" " unit_system: bad\n" "\n\n"
|
||||
BAD_CORE_CONFIG = "homeassistant:\n unit_system: bad\n\n\n"
|
||||
|
||||
|
||||
def log_ha_config(conf):
|
||||
@@ -106,8 +106,7 @@ async def test_component_platform_not_found_2(hass, loop):
|
||||
async def test_package_invalid(hass, loop):
|
||||
"""Test a valid platform setup."""
|
||||
files = {
|
||||
YAML_CONFIG_FILE: BASE_CONFIG
|
||||
+ (" packages:\n" " p1:\n" ' group: ["a"]')
|
||||
YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]')
|
||||
}
|
||||
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
||||
res = await async_check_ha_config_file(hass)
|
||||
|
||||
@@ -340,7 +340,7 @@ async def test_no_unnecessary_changes(registry):
|
||||
identifiers={("hue", "456"), ("bla", "123")},
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.helpers.device_registry" ".DeviceRegistry.async_schedule_save"
|
||||
"homeassistant.helpers.device_registry.DeviceRegistry.async_schedule_save"
|
||||
) as mock_save:
|
||||
entry2 = registry.async_get_or_create(
|
||||
config_entry_id="1234", identifiers={("hue", "456")}
|
||||
|
||||
@@ -115,7 +115,7 @@ async def test_setup_recovers_when_setup_raises(hass):
|
||||
|
||||
|
||||
@asynctest.patch(
|
||||
"homeassistant.helpers.entity_component.EntityComponent" ".async_setup_platform",
|
||||
"homeassistant.helpers.entity_component.EntityComponent.async_setup_platform",
|
||||
return_value=mock_coro(),
|
||||
)
|
||||
@asynctest.patch(
|
||||
@@ -137,7 +137,7 @@ async def test_setup_does_discovery(mock_setup_component, mock_setup, hass):
|
||||
assert ("platform_test", {}, {"msg": "discovery_info"}) == mock_setup.call_args[0]
|
||||
|
||||
|
||||
@asynctest.patch("homeassistant.helpers.entity_platform." "async_track_time_interval")
|
||||
@asynctest.patch("homeassistant.helpers.entity_platform.async_track_time_interval")
|
||||
async def test_set_scan_interval_via_config(mock_track, hass):
|
||||
"""Test the setting of the scan interval via configuration."""
|
||||
|
||||
@@ -460,5 +460,5 @@ async def test_extract_all_use_match_all(hass, caplog):
|
||||
ent.entity_id for ent in await component.async_extract_from_service(call)
|
||||
)
|
||||
assert (
|
||||
"Not passing an entity ID to a service to target all entities is " "deprecated"
|
||||
"Not passing an entity ID to a service to target all entities is deprecated"
|
||||
) not in caplog.text
|
||||
@@ -134,7 +134,7 @@ async def test_update_state_adds_entities_with_update_before_add_false(hass):
|
||||
assert not ent.update.called
|
||||
|
||||
|
||||
@asynctest.patch("homeassistant.helpers.entity_platform." "async_track_time_interval")
|
||||
@asynctest.patch("homeassistant.helpers.entity_platform.async_track_time_interval")
|
||||
async def test_set_scan_interval_via_platform(mock_track, hass):
|
||||
"""Test the setting of the scan interval via platform."""
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ async def test_call_later(hass):
|
||||
now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.event" ".async_track_point_in_utc_time"
|
||||
"homeassistant.helpers.event.async_track_point_in_utc_time"
|
||||
) as mock, patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
async_call_later(hass, 3, action)
|
||||
|
||||
@@ -825,7 +825,7 @@ async def test_async_call_later(hass):
|
||||
now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.event" ".async_track_point_in_utc_time"
|
||||
"homeassistant.helpers.event.async_track_point_in_utc_time"
|
||||
) as mock, patch("homeassistant.util.dt.utcnow", return_value=now):
|
||||
remove = async_call_later(hass, 3, action)
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ async def test_call_with_match_all(
|
||||
mock_entities["light.living_room"],
|
||||
]
|
||||
assert (
|
||||
"Not passing an entity ID to a service to target " "all entities is deprecated"
|
||||
"Not passing an entity ID to a service to target all entities is deprecated"
|
||||
) not in caplog.text
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ def test_iterating_all_states(hass):
|
||||
|
||||
def test_iterating_domain_states(hass):
|
||||
"""Test iterating domain states."""
|
||||
tmpl_str = "{% for state in states.sensor %}" "{{ state.state }}{% endfor %}"
|
||||
tmpl_str = "{% for state in states.sensor %}{{ state.state }}{% endfor %}"
|
||||
|
||||
info = render_to_info(hass, tmpl_str)
|
||||
assert_result_info(info, "", domains=["sensor"])
|
||||
@@ -818,7 +818,7 @@ def test_states_function(hass):
|
||||
|
||||
|
||||
@patch(
|
||||
"homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable",
|
||||
"homeassistant.helpers.template.TemplateEnvironment.is_safe_callable",
|
||||
return_value=True,
|
||||
)
|
||||
def test_now(mock_is_safe, hass):
|
||||
@@ -832,7 +832,7 @@ def test_now(mock_is_safe, hass):
|
||||
|
||||
|
||||
@patch(
|
||||
"homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable",
|
||||
"homeassistant.helpers.template.TemplateEnvironment.is_safe_callable",
|
||||
return_value=True,
|
||||
)
|
||||
def test_utcnow(mock_is_safe, hass):
|
||||
@@ -1260,18 +1260,18 @@ async def test_expand(hass):
|
||||
hass.states.async_set("test.object", "happy")
|
||||
|
||||
info = render_to_info(
|
||||
hass, "{{ expand('test.object') | map(attribute='entity_id')" " | join(', ') }}"
|
||||
hass, "{{ expand('test.object') | map(attribute='entity_id') | join(', ') }}"
|
||||
)
|
||||
assert_result_info(info, "test.object", [])
|
||||
|
||||
info = render_to_info(
|
||||
hass,
|
||||
"{{ expand('group.new_group') | map(attribute='entity_id')" " | join(', ') }}",
|
||||
"{{ expand('group.new_group') | map(attribute='entity_id') | join(', ') }}",
|
||||
)
|
||||
assert_result_info(info, "", ["group.new_group"])
|
||||
|
||||
info = render_to_info(
|
||||
hass, "{{ expand(states.group) | map(attribute='entity_id')" " | join(', ') }}"
|
||||
hass, "{{ expand(states.group) | map(attribute='entity_id') | join(', ') }}"
|
||||
)
|
||||
assert_result_info(info, "", [], ["group"])
|
||||
|
||||
@@ -1279,12 +1279,12 @@ async def test_expand(hass):
|
||||
|
||||
info = render_to_info(
|
||||
hass,
|
||||
"{{ expand('group.new_group') | map(attribute='entity_id')" " | join(', ') }}",
|
||||
"{{ expand('group.new_group') | map(attribute='entity_id') | join(', ') }}",
|
||||
)
|
||||
assert_result_info(info, "test.object", ["group.new_group"])
|
||||
|
||||
info = render_to_info(
|
||||
hass, "{{ expand(states.group) | map(attribute='entity_id')" " | join(', ') }}"
|
||||
hass, "{{ expand(states.group) | map(attribute='entity_id') | join(', ') }}"
|
||||
)
|
||||
assert_result_info(info, "test.object", ["group.new_group"], ["group"])
|
||||
|
||||
@@ -1437,7 +1437,7 @@ def test_closest_function_to_state(hass):
|
||||
|
||||
assert (
|
||||
template.Template(
|
||||
"{{ closest(states.zone.far_away, " "states.test_domain).entity_id }}", hass
|
||||
"{{ closest(states.zone.far_away, states.test_domain).entity_id }}", hass
|
||||
).async_render()
|
||||
== "test_domain.closest_zone"
|
||||
)
|
||||
@@ -1471,7 +1471,7 @@ def test_closest_function_state_with_invalid_location(hass):
|
||||
|
||||
assert (
|
||||
template.Template(
|
||||
"{{ closest(states.test_domain.closest_home, " "states) }}", hass
|
||||
"{{ closest(states.test_domain.closest_home, states) }}", hass
|
||||
).async_render()
|
||||
== "None"
|
||||
)
|
||||
@@ -1517,7 +1517,7 @@ def test_extract_entities_none_exclude_stuff(hass):
|
||||
|
||||
assert (
|
||||
template.extract_entities(
|
||||
"{{ closest(states.zone.far_away, " "states.test_domain).entity_id }}"
|
||||
"{{ closest(states.zone.far_away, states.test_domain).entity_id }}"
|
||||
)
|
||||
== MATCH_ALL
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ BASE_CONFIG = (
|
||||
"\n\n"
|
||||
)
|
||||
|
||||
BAD_CORE_CONFIG = "homeassistant:\n" " unit_system: bad\n" "\n\n"
|
||||
BAD_CORE_CONFIG = "homeassistant:\n unit_system: bad\n\n\n"
|
||||
|
||||
|
||||
def normalize_yaml_files(check_dict):
|
||||
@@ -92,8 +92,8 @@ def test_secrets(isfile_patch, loop):
|
||||
|
||||
files = {
|
||||
get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG
|
||||
+ ("http:\n" " cors_allowed_origins: !secret http_pw"),
|
||||
secrets_path: ("logger: debug\n" "http_pw: http://google.com"),
|
||||
+ ("http:\n cors_allowed_origins: !secret http_pw"),
|
||||
secrets_path: ("logger: debug\nhttp_pw: http://google.com"),
|
||||
}
|
||||
|
||||
with patch_yaml_files(files):
|
||||
@@ -122,8 +122,7 @@ def test_secrets(isfile_patch, loop):
|
||||
def test_package_invalid(isfile_patch, loop):
|
||||
"""Test a valid platform setup."""
|
||||
files = {
|
||||
YAML_CONFIG_FILE: BASE_CONFIG
|
||||
+ (" packages:\n" " p1:\n" ' group: ["a"]')
|
||||
YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]')
|
||||
}
|
||||
with patch_yaml_files(files):
|
||||
res = check_config.check(get_test_config_dir())
|
||||
|
||||
@@ -392,7 +392,7 @@ class TestSecrets(unittest.TestCase):
|
||||
with pytest.raises(HomeAssistantError):
|
||||
load_yaml(
|
||||
os.path.join(self._sub_folder_path, "sub.yaml"),
|
||||
"http:\n" " api_password: !secret test",
|
||||
"http:\n api_password: !secret test",
|
||||
)
|
||||
|
||||
def test_secrets_keyring(self):
|
||||
@@ -431,9 +431,9 @@ class TestSecrets(unittest.TestCase):
|
||||
|
||||
def test_secrets_are_not_dict(self):
|
||||
"""Did secrets handle non-dict file."""
|
||||
FILES[self._secret_path] = (
|
||||
"- http_pw: pwhttp\n" " comp1_un: un1\n" " comp1_pw: pw1\n"
|
||||
)
|
||||
FILES[
|
||||
self._secret_path
|
||||
] = "- http_pw: pwhttp\n comp1_un: un1\n comp1_pw: pw1\n"
|
||||
yaml.clear_secret_cache()
|
||||
with pytest.raises(HomeAssistantError):
|
||||
load_yaml(
|
||||
|
||||
Reference in new issue
Block a user