コード例 #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
ファイル: test_mqtt.py プロジェクト: bdfoster/blumate
    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
ファイル: test_mqtt.py プロジェクト: Teagan42/home-assistant
    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)
コード例 #7
0
    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
ファイル: test_mqtt.py プロジェクト: tmcarr/home-assistant
    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)
コード例 #14
0
 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
ファイル: test_mqtt.py プロジェクト: sonkesun/home-assistant
 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)
コード例 #19
0
 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)
コード例 #20
0
 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
ファイル: test_mqtt.py プロジェクト: sara0871/-.gitignore-
 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
ファイル: test_mqtt.py プロジェクト: FanaHOVA/home-assistant
 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
ファイル: test_mqtt.py プロジェクト: FanaHOVA/home-assistant
 def setUp(self):  # pylint: disable=invalid-name
     """ Init needed objects. """
     self.hass = get_test_home_assistant()
     mock_mqtt_component(self.hass)
コード例 #26
0
ファイル: test_mqtt.py プロジェクト: x86Labs/home-assistant
 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)
コード例 #29
0
 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)
コード例 #31
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)