예제 #1
0
    def setup_method(self, method):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.assertTrue(
            setup_component(
                self.hass,
                device_tracker.DOMAIN,
                {
                    device_tracker.DOMAIN: {
                        CONF_PLATFORM: "owntracks",
                        CONF_MAX_GPS_ACCURACY: 200,
                        CONF_WAYPOINT_IMPORT: True,
                        CONF_WAYPOINT_WHITELIST: ["jon", "greg"],
                    }
                },
            )
        )

        self.hass.states.set("zone.inner", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10})

        self.hass.states.set(
            "zone.inner_2", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10}
        )

        self.hass.states.set(
            "zone.outer", "zoning", {"name": "zone", "latitude": 2.0, "longitude": 1.0, "radius": 100000}
        )

        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
        owntracks.REGIONS_ENTERED = defaultdict(list)
        owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
예제 #2
0
    def setUp(self):  # pylint: disable=invalid-name
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.calls = []

        def record_call(service):
            self.calls.append(service)

        self.hass.services.register('test', 'automation', record_call)
예제 #3
0
    def setUp(self):  # pylint: disable=invalid-name
        self.hass = ha.HomeAssistant()
        mock_mqtt_component(self.hass)
        self.calls = []

        def record_call(service):
            self.calls.append(service)

        self.hass.services.register("test", "automation", record_call)
예제 #4
0
    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.hass.config.components.append('group')
        mock_mqtt_component(self.hass)
        self.calls = []

        def record_call(service):
            self.calls.append(service)

        self.hass.services.register('test', 'automation', record_call)
예제 #5
0
    def setUp(self):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.hass.config.components.append('group')
        mock_mqtt_component(self.hass)
        self.calls = []

        @callback
        def record_call(service):
            """Helper to record calls."""
            self.calls.append(service)

        self.hass.services.register('test', 'automation', record_call)
예제 #6
0
    def setup_method(self, method):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.assertTrue(device_tracker.setup(self.hass, {
            device_tracker.DOMAIN: {
                CONF_PLATFORM: 'owntracks',
                CONF_MAX_GPS_ACCURACY: 200
            }}))

        self.hass.states.set(
            'zone.inner', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.inner_2', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.outer', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.0,
                'longitude': 1.0,
                'radius': 100000
            })

        self.hass.states.set(
            'zone.passive', 'zoning',
            {
                'name': 'zone',
                'latitude': 3.0,
                'longitude': 1.0,
                'radius': 10,
                'passive': True
            })
        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
        owntracks.REGIONS_ENTERED = defaultdict(list)
        owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
    def setup_method(self, method):
        """Set up things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
            sensor.DOMAIN: {
                CONF_PLATFORM: 'mqtt_room',
                CONF_NAME: NAME,
                CONF_DEVICE_ID: DEVICE_ID,
                CONF_STATE_TOPIC: 'room_presence',
                CONF_QOS: DEFAULT_QOS,
                CONF_TIMEOUT: 5
            }}))

        # Clear state between tests
        self.hass.states.set(SENSOR_STATE, None)
예제 #8
0
    def setUp(self):  # pylint: disable=invalid-name
        """Set up things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.mock_publish = mock_mqtt_component(self.hass)

        self.default_config = {
            CONF_PLATFORM: 'mqtt',
            CONF_NAME: 'mqtttest',
            CONF_COMMAND_TOPIC: 'vacuum/command',
            mqtt.CONF_SEND_COMMAND_TOPIC: 'vacuum/send_command',
            mqtt.CONF_BATTERY_LEVEL_TOPIC: 'vacuum/state',
            mqtt.CONF_BATTERY_LEVEL_TEMPLATE:
                '{{ value_json.battery_level }}',
            mqtt.CONF_CHARGING_TOPIC: 'vacuum/state',
            mqtt.CONF_CHARGING_TEMPLATE: '{{ value_json.charging }}',
            mqtt.CONF_CLEANING_TOPIC: 'vacuum/state',
            mqtt.CONF_CLEANING_TEMPLATE: '{{ value_json.cleaning }}',
            mqtt.CONF_DOCKED_TOPIC: 'vacuum/state',
            mqtt.CONF_DOCKED_TEMPLATE: '{{ value_json.docked }}',
            mqtt.CONF_STATE_TOPIC: 'vacuum/state',
            mqtt.CONF_STATE_TEMPLATE: '{{ value_json.state }}',
            mqtt.CONF_FAN_SPEED_TOPIC: 'vacuum/state',
            mqtt.CONF_FAN_SPEED_TEMPLATE: '{{ value_json.fan_speed }}',
            mqtt.CONF_SET_FAN_SPEED_TOPIC: 'vacuum/set_fan_speed',
            mqtt.CONF_FAN_SPEED_LIST: ['min', 'medium', 'high', 'max'],
        }
예제 #9
0
    def setup_method(self, _):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        mock_component(self.hass, 'group')
        mock_component(self.hass, 'zone')

        patcher = patch('homeassistant.components.device_tracker.'
                        'DeviceTracker.async_update_config')
        patcher.start()
        self.addCleanup(patcher.stop)

        orig_context = owntracks.OwnTracksContext

        def store_context(*args):
            self.context = orig_context(*args)
            return self.context

        with patch('homeassistant.components.device_tracker.async_load_config',
                   return_value=mock_coro([])), \
                patch('homeassistant.components.device_tracker.'
                      'load_yaml_config_file', return_value=mock_coro({})), \
                patch.object(owntracks, 'OwnTracksContext', store_context), \
                assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN, {
                device_tracker.DOMAIN: {
                    CONF_PLATFORM: 'owntracks',
                    CONF_MAX_GPS_ACCURACY: 200,
                    CONF_WAYPOINT_IMPORT: True,
                    CONF_WAYPOINT_WHITELIST: ['jon', 'greg']
                }})

        self.hass.states.set(
            'zone.inner', 'zoning', INNER_ZONE)

        self.hass.states.set(
            'zone.inner_2', 'zoning', INNER_ZONE)

        self.hass.states.set(
            'zone.outer', 'zoning', OUTER_ZONE)

        # Clear state between tests
        # NB: state "None" is not a state that is created by Device
        # so when we compare state to None in the tests this
        # is really checking that it is still in its original
        # test case state. See Device.async_update.
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
예제 #10
0
    def setup_method(self, method):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        mock_component(self.hass, 'group')
        mock_component(self.hass, 'zone')

        patch_load = patch(
            'homeassistant.components.device_tracker.async_load_config',
            return_value=mock_coro([]))
        patch_load.start()
        self.addCleanup(patch_load.stop)

        patch_save = patch('homeassistant.components.device_tracker.'
                           'DeviceTracker.async_update_config')
        patch_save.start()
        self.addCleanup(patch_save.stop)
예제 #11
0
    def setup_method(self, _):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        with assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN, {
                device_tracker.DOMAIN: {
                    CONF_PLATFORM: 'owntracks',
                    CONF_MAX_GPS_ACCURACY: 200,
                    CONF_WAYPOINT_IMPORT: True,
                    CONF_WAYPOINT_WHITELIST: ['jon', 'greg']
                }})

        self.hass.states.set(
            'zone.inner', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.inner_2', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.outer', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.0,
                'longitude': 1.0,
                'radius': 100000
            })

        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
        owntracks.REGIONS_ENTERED = defaultdict(list)
        owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
예제 #12
0
    def setup_method(self, method):
        """ Init needed objects. """
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.assertTrue(device_tracker.setup(self.hass, {
            device_tracker.DOMAIN: {
                CONF_PLATFORM: 'owntracks'
            }}))

        self.hass.states.set(
            'zone.inner', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.inner_2', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.outer', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.0,
                'longitude': 1.0,
                'radius': 100000
            })
        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
        owntracks.REGIONS_ENTERED = defaultdict(list)
        owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
예제 #13
0
    def setup_method(self, method):
        """ Init needed objects. """
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        self.assertTrue(device_tracker.setup(self.hass, {device_tracker.DOMAIN: {CONF_PLATFORM: "owntracks"}}))

        self.hass.states.set("zone.inner", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10})

        self.hass.states.set(
            "zone.inner_2", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10}
        )

        self.hass.states.set(
            "zone.outer", "zoning", {"name": "zone", "latitude": 2.0, "longitude": 1.0, "radius": 100000}
        )

        self.hass.states.set(
            "zone.passive", "zoning", {"name": "zone", "latitude": 3.0, "longitude": 1.0, "radius": 10, "passive": True}
        )
        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
        owntracks.REGIONS_ENTERED = defaultdict(list)
        owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
 def setUp(self):
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.mock_publish = mock_mqtt_component(self.hass)
예제 #15
0
 def setUp(self):  # pylint: disable=invalid-name
     self.hass = get_test_home_assistant()
     self.mock_publish = mock_mqtt_component(self.hass)
예제 #16
0
 def setUp(self):  # pylint: disable=invalid-name
     self.hass = ha.HomeAssistant()
     self.mock_publish = mock_mqtt_component(self.hass)
예제 #17
0
 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.hass.config_entries._async_schedule_save = Mock()
     mock_mqtt_component(self.hass)
예제 #18
0
 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)
 def setUp(self):  # pylint: disable=invalid-name
     """Setup things to be run when tests are started."""
     super(TestMqttEventStream, self).setUp()
     self.hass = get_test_home_assistant()
     self.mock_mqtt = mock_mqtt_component(self.hass)
 def setUp(self):  # pylint: disable=invalid-name
     super(TestMqttEventStream, self).setUp()
     self.hass = get_test_home_assistant()
     self.mock_mqtt = mock_mqtt_component(self.hass)
예제 #21
0
 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.mock_publish = mock_mqtt_component(self.hass)
     self.hass.config.units = METRIC_SYSTEM
예제 #22
0
파일: test_mqtt.py 프로젝트: timmo001/core
 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.hass.config_entries._async_schedule_save = Mock()
     mock_mqtt_component(self.hass)
예제 #23
0
 def setUp(self):  # pylint: disable=invalid-name
     self.hass = ha.HomeAssistant()
     self.mock_publish = mock_mqtt_component(self.hass)
예제 #24
0
    def setup_method(self, _):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        mock_mqtt_component(self.hass)
        mock_component(self.hass, 'group')
        mock_component(self.hass, 'zone')

        patcher = patch('homeassistant.components.device_tracker.'
                        'DeviceTracker.async_update_config')
        patcher.start()
        self.addCleanup(patcher.stop)

        orig_context = owntracks.OwnTracksContext

        def store_context(*args):
            self.context = orig_context(*args)
            return self.context

        with patch('homeassistant.components.device_tracker.async_load_config',
                   return_value=mock_coro([])), \
                patch('homeassistant.components.device_tracker.'
                      'load_yaml_config_file', return_value=mock_coro({})), \
                patch.object(owntracks, 'OwnTracksContext', store_context), \
                assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN, {
                device_tracker.DOMAIN: {
                    CONF_PLATFORM: 'owntracks',
                    CONF_MAX_GPS_ACCURACY: 200,
                    CONF_WAYPOINT_IMPORT: True,
                    CONF_WAYPOINT_WHITELIST: ['jon', 'greg']
                }})

        self.hass.states.set(
            'zone.inner', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.inner_2', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.1,
                'longitude': 1.1,
                'radius': 10
            })

        self.hass.states.set(
            'zone.outer', 'zoning',
            {
                'name': 'zone',
                'latitude': 2.0,
                'longitude': 1.0,
                'radius': 100000
            })

        # Clear state between teste
        self.hass.states.set(DEVICE_TRACKER_STATE, None)
예제 #25
0
 def setUp(self):  # pylint: disable=invalid-name
     """ Init needed objects. """
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)
예제 #26
0
 def setUp(self):  # pylint: disable=invalid-name
     """ Init needed objects. """
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)
예제 #27
0
 def setUp(self):  # pylint: disable=invalid-name
     self.hass = get_test_home_assistant(1)
     mock_mqtt_component(self.hass)
     self.calls = []
예제 #28
0
 def setup_method(self, method):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)
 def setUp(self):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.mock_publish = mock_mqtt_component(self.hass)
예제 #30
0
 def setUp(self):  # pylint: disable=invalid-name
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.mock_publish = mock_mqtt_component(self.hass)
 def setup_method(self, method):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)