示例#1
0
    def test_platform_setup(self):
        """Test platform setup."""
        config = {'name': 'test', 'platform': 'universal'}
        bad_config = {'platform': 'universal'}
        entities = []

        def add_entities(new_entities):
            """Add devices to list."""
            for dev in new_entities:
                entities.append(dev)

        setup_ok = True
        try:
            run_coroutine_threadsafe(
                universal.async_setup_platform(self.hass,
                                               validate_config(bad_config),
                                               add_entities),
                self.hass.loop).result()
        except MultipleInvalid:
            setup_ok = False
        assert not setup_ok
        assert 0 == len(entities)

        run_coroutine_threadsafe(
            universal.async_setup_platform(self.hass, validate_config(config),
                                           add_entities),
            self.hass.loop).result()
        assert 1 == len(entities)
        assert 'test' == entities[0].name
    def test_platform_setup(self):
        """Test platform setup."""
        config = {'name': 'test', 'platform': 'universal'}
        bad_config = {'platform': 'universal'}
        entities = []

        def add_entities(new_entities):
            """Add devices to list."""
            for dev in new_entities:
                entities.append(dev)

        setup_ok = True
        try:
            run_coroutine_threadsafe(
                universal.async_setup_platform(
                    self.hass, validate_config(bad_config), add_entities),
                self.hass.loop).result()
        except MultipleInvalid:
            setup_ok = False
        assert not setup_ok
        assert 0 == len(entities)

        run_coroutine_threadsafe(
            universal.async_setup_platform(
                self.hass, validate_config(config), add_entities),
            self.hass.loop).result()
        assert 1 == len(entities)
        assert 'test' == entities[0].name
示例#3
0
    def test_platform_setup(self):
        """Test platform setup."""
        config = {'name': 'test', 'platform': 'universal'}
        bad_config = {'platform': 'universal'}
        entities = []

        def add_devices(new_entities):
            """Add devices to list."""
            for dev in new_entities:
                entities.append(dev)

        run_coroutine_threadsafe(
            universal.async_setup_platform(self.hass, bad_config, add_devices),
            self.hass.loop).result()
        self.assertEqual(0, len(entities))

        run_coroutine_threadsafe(
            universal.async_setup_platform(self.hass, config, add_devices),
            self.hass.loop).result()
        self.assertEqual(1, len(entities))
        self.assertEqual('test', entities[0].name)
    def test_platform_setup(self):
        """Test platform setup."""
        config = {'name': 'test', 'platform': 'universal'}
        bad_config = {'platform': 'universal'}
        entities = []

        def add_devices(new_entities):
            """Add devices to list."""
            for dev in new_entities:
                entities.append(dev)

        run_coroutine_threadsafe(
            universal.async_setup_platform(self.hass, bad_config, add_devices),
            self.hass.loop).result()
        self.assertEqual(0, len(entities))

        run_coroutine_threadsafe(
            universal.async_setup_platform(self.hass, config, add_devices),
            self.hass.loop).result()
        self.assertEqual(1, len(entities))
        self.assertEqual('test', entities[0].name)