Fix canary flaky test (#11519)

This commit is contained in:
Paulus Schoutsen 2018-01-07 15:05:19 -08:00 committed by GitHub
parent 8267a21bfe
commit bccd880395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,9 @@
"""The tests for the Canary sensor platform.""" """The tests for the Canary sensor platform."""
import copy import copy
import unittest import unittest
from unittest.mock import patch, Mock from unittest.mock import Mock
from canary.api import SensorType from canary.api import SensorType
from homeassistant.components import canary as base_canary
from homeassistant.components.canary import DATA_CANARY from homeassistant.components.canary import DATA_CANARY
from homeassistant.components.sensor import canary from homeassistant.components.sensor import canary
from homeassistant.components.sensor.canary import CanarySensor from homeassistant.components.sensor.canary import CanarySensor
@ -39,16 +38,13 @@ class TestCanarySensorSetup(unittest.TestCase):
"""Stop everything that was started.""" """Stop everything that was started."""
self.hass.stop() self.hass.stop()
@patch('homeassistant.components.canary.CanaryData') def test_setup_sensors(self):
def test_setup_sensors(self, mock_canary):
"""Test the sensor setup.""" """Test the sensor setup."""
base_canary.setup(self.hass, self.config)
online_device_at_home = mock_device(20, "Dining Room", True) online_device_at_home = mock_device(20, "Dining Room", True)
offline_device_at_home = mock_device(21, "Front Yard", False) offline_device_at_home = mock_device(21, "Front Yard", False)
online_device_at_work = mock_device(22, "Office", True) online_device_at_work = mock_device(22, "Office", True)
self.hass.data[DATA_CANARY] = mock_canary() self.hass.data[DATA_CANARY] = Mock()
self.hass.data[DATA_CANARY].locations = [ self.hass.data[DATA_CANARY].locations = [
mock_location("Home", True, devices=[online_device_at_home, mock_location("Home", True, devices=[online_device_at_home,
offline_device_at_home]), offline_device_at_home]),