def test_discovering_configuration_auto_detect_fails( self, mock_detect, mock_elevation): """Test config remains unchanged if discovery fails.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config(hass, {}) blankConfig = Config() assert config.latitude == blankConfig.latitude assert config.longitude == blankConfig.longitude assert config.elevation == blankConfig.elevation assert config.location_name == blankConfig.location_name assert config.units == blankConfig.units assert config.time_zone == blankConfig.time_zone
def test_discovering_configuration_auto_detect_fails( self, mock_detect, mock_elevation): """Test config remains unchanged if discovery fails.""" self.hass.config = Config() run_coroutine_threadsafe( config_util.async_process_ha_core_config(self.hass, {}), self.hass.loop).result() blankConfig = Config() assert self.hass.config.latitude == blankConfig.latitude assert self.hass.config.longitude == blankConfig.longitude assert self.hass.config.elevation == blankConfig.elevation assert self.hass.config.location_name == blankConfig.location_name assert self.hass.config.units == blankConfig.units assert self.hass.config.time_zone == blankConfig.time_zone
async def test_discovering_configuration_auto_detect_fails( mock_detect, mock_elevation, hass): """Test config remains unchanged if discovery fails.""" hass.config = Config() hass.config.config_dir = "/test/config" await config_util.async_process_ha_core_config(hass, {}) blankConfig = Config() assert hass.config.latitude == blankConfig.latitude assert hass.config.longitude == blankConfig.longitude assert hass.config.elevation == blankConfig.elevation assert hass.config.location_name == blankConfig.location_name assert hass.config.units == blankConfig.units assert hass.config.time_zone == blankConfig.time_zone assert len(hass.config.whitelist_external_dirs) == 1 assert "/test/config/www" in hass.config.whitelist_external_dirs
def test_discovering_configuration(self, mock_detect, mock_elevation): """Test auto discovery for missing core configs.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config(hass, {}) assert config.latitude == 32.8594 assert config.longitude == -117.2073 assert config.elevation == 101 assert config.location_name == 'San Diego' assert config.temperature_unit == TEMP_FAHRENHEIT assert config.time_zone.zone == 'America/Los_Angeles'
def test_discovering_configuration(self, mock_detect, mock_elevation): """Test auto discovery for missing core configs.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config(hass, {}) assert config.latitude == 32.8594 assert config.longitude == -117.2073 assert config.elevation == 101 assert config.location_name == 'San Diego' assert config.units.name == CONF_UNIT_SYSTEM_METRIC assert config.units.is_metric assert config.time_zone.zone == 'America/Los_Angeles'
def test_loading_configuration(self): """Test loading core config onto hass object.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config(hass, { 'latitude': 60, 'longitude': 50, 'elevation': 25, 'name': 'Huis', 'temperature_unit': 'F', 'time_zone': 'America/New_York', }) assert config.latitude == 60 assert config.longitude == 50 assert config.elevation == 25 assert config.location_name == 'Huis' assert config.temperature_unit == TEMP_FAHRENHEIT assert config.time_zone.zone == 'America/New_York'
def test_loading_configuration_temperature_unit(self): """Test backward compatibility when loading core config.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config( hass, { 'latitude': 60, 'longitude': 50, 'elevation': 25, 'name': 'Huis', CONF_TEMPERATURE_UNIT: 'C', 'time_zone': 'America/New_York', }) assert config.latitude == 60 assert config.longitude == 50 assert config.elevation == 25 assert config.location_name == 'Huis' assert config.units.name == CONF_UNIT_SYSTEM_METRIC assert config.time_zone.zone == 'America/New_York'
def test_loading_configuration(self): """Test loading core config onto hass object.""" config = Config() hass = mock.Mock(config=config) config_util.process_ha_core_config( hass, { 'latitude': 60, 'longitude': 50, 'elevation': 25, 'name': 'Huis', CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, 'time_zone': 'America/New_York', }) assert config.latitude == 60 assert config.longitude == 50 assert config.elevation == 25 assert config.location_name == 'Huis' assert config.units.name == CONF_UNIT_SYSTEM_IMPERIAL assert config.time_zone.zone == 'America/New_York'