コード例 #1
0
    def test_setup_platform_valid_config(self, mock_update):
        """Check a valid configuration and call add_devices with sensor."""
        with assert_setup_component(0, 'sensor'):
            assert setup_component(self.hass, 'sensor', TEST_CONFIG)

        add_devices = Mock()
        tcp.setup_platform(None, TEST_CONFIG['sensor'], add_devices)
        assert add_devices.called
        assert isinstance(add_devices.call_args[0][0][0], tcp.TcpSensor)
コード例 #2
0
def test_setup_platform_valid_config():
    """ Should check the supplied config and call add_entities with Sensor. """
    add_entities = Mock()
    ret = tcp.setup_platform(None, TEST_CONFIG, add_entities)
    assert ret is None, "setup_platform() should return None if successful."
    assert add_entities.called
    assert isinstance(add_entities.call_args[0][0][0], tcp.Sensor)
コード例 #3
0
ファイル: test_tcp.py プロジェクト: x86Labs/home-assistant
def test_setup_platform_valid_config():
    """ Should check the supplied config and call add_entities with Sensor. """
    add_entities = Mock()
    ret = tcp.setup_platform(None, TEST_CONFIG, add_entities)
    assert ret is None, "setup_platform() should return None if successful."
    assert add_entities.called
    assert isinstance(add_entities.call_args[0][0][0], tcp.Sensor)
コード例 #4
0
def test_setup_platform_invalid_config():
    """ Should check the supplied config and return False if it is invalid. """
    config = copy(TEST_CONFIG)
    del config[tcp.CONF_HOST]
    assert tcp.setup_platform(None, config, None) is False
コード例 #5
0
ファイル: test_tcp.py プロジェクト: x86Labs/home-assistant
def test_setup_platform_invalid_config():
    """ Should check the supplied config and return False if it is invalid. """
    config = copy(TEST_CONFIG)
    del config[tcp.CONF_HOST]
    assert tcp.setup_platform(None, config, None) is False