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)
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)
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