Пример #1
0
    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.events = []
        self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
            'notify': [{
                'name': 'demo1',
                'platform': 'demo'
            }, {
                'name': 'demo2',
                'platform': 'demo'
            }]
        }))

        self.service = group.get_service(self.hass, {'services': [
            {'service': 'demo1'},
            {'service': 'demo2',
             'data': {'target': 'unnamed device',
                      'data': {'test': 'message'}}}]})

        assert self.service is not None

        def record_event(event):
            """Record event to send notification."""
            self.events.append(event)

        self.hass.bus.listen("notify", record_event)
Пример #2
0
    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.events = []
        self.service1 = MagicMock()
        self.service2 = MagicMock()

        def mock_get_service(hass, config):
            if config['name'] == 'demo1':
                return self.service1
            else:
                return self.service2

        with assert_setup_component(2), \
                patch.object(demo, 'get_service', mock_get_service):
            setup_component(self.hass, notify.DOMAIN, {
                'notify': [{
                    'name': 'demo1',
                    'platform': 'demo'
                }, {
                    'name': 'demo2',
                    'platform': 'demo'
                }]
            })

        self.service = group.get_service(self.hass, {'services': [
            {'service': 'demo1'},
            {'service': 'demo2',
             'data': {'target': 'unnamed device',
                      'data': {'test': 'message'}}}]})

        assert self.service is not None
Пример #3
0
    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.events = []
        self.service1 = MagicMock()
        self.service2 = MagicMock()

        def mock_get_service(hass, config, discovery_info=None):
            if config['name'] == 'demo1':
                return self.service1
            else:
                return self.service2

        with assert_setup_component(2), \
                patch.object(demo, 'get_service', mock_get_service):
            setup_component(self.hass, notify.DOMAIN, {
                'notify': [{
                    'name': 'demo1',
                    'platform': 'demo'
                }, {
                    'name': 'demo2',
                    'platform': 'demo'
                }]
            })

        self.service = group.get_service(self.hass, {'services': [
            {'service': 'demo1'},
            {'service': 'demo2',
             'data': {'target': 'unnamed device',
                      'data': {'test': 'message'}}}]})

        assert self.service is not None
Пример #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.events = []
        self.assertTrue(
            notify.setup(self.hass,
                         {'notify': {
                             'name': 'demo1',
                             'platform': 'demo'
                         }}))
        self.assertTrue(
            notify.setup(self.hass,
                         {'notify': {
                             'name': 'demo2',
                             'platform': 'demo'
                         }}))

        self.service = group.get_service(
            self.hass, {
                'services': [{
                    'service': 'demo1'
                }, {
                    'service': 'demo2',
                    'data': {
                        'target': 'unnamed device',
                        'data': {
                            'test': 'message'
                        }
                    }
                }]
            })

        assert self.service is not None

        def record_event(event):
            """Record event to send notification."""
            self.events.append(event)

        self.hass.bus.listen("notify", record_event)