core/tests/components/bsblan/__init__.py

19 lines
633 B
Python
Raw Normal View History

Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
"""Tests for the bsblan integration."""
Add tests for BSBLAN climate component (#124524) * chore: Add tests for BSBLAN climate component * fix return types * fix MAC data * chore: Update BSBLAN climate component tests used setup from conftest added setup for farhenheit temp unit * chore: Update BSBLAN climate component tests use syrupy to compare results * add test for temp_unit * update climate tests set current_temperature to None in test case. Is this the correct way for testing? * chore: Update BSBLAN diagnostics to handle asynchronous data retrieval * chore: Refactor BSBLAN conftest.py to simplify fixture and patching * chore: Update BSBLAN climate component tests 100% test coverage * chore: Update BSBLAN diagnostics to handle asynchronous data retrieval * chore: Update snapshots * Fix BSBLAN climate test for async_set_preset_mode - Update test_async_set_preset_mode to correctly handle ServiceValidationError - Check for specific translation key instead of full error message - Ensure consistency between local tests and CI environment - Import ServiceValidationError explicitly for clarity * Update homeassistant/components/bsblan/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * chore: Update BSBLAN conftest.py to simplify fixture and patching * chore: Update BSBLAN integration setup function parameter name * chore: removed set_static_value * refactor: Improve BSBLANClimate async_set_preset_mode method This commit refactors the async_set_preset_mode method in the BSBLANClimate class to improve code readability and maintainability. The method now checks if the HVAC mode is not set to AUTO and the preset mode is not NONE before raising a ServiceValidationError. Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * refactor: Improve tests test_celsius_fahrenheit test_climate_entity_properties test_async_set_hvac_mode test_async_set_preset_mode still broken. Not sure why hvac mode will not set. THis causes error with preset mode set * update snapshot * fix DOMAIN bsblan * refactor: Improve BSBLANClimate async_set_data method * refactor: fix last tests * refactor: Simplify async_get_config_entry_diagnostics method * refactor: Improve BSBLANClimate async_set_temperature method This commit improves the async_set_temperature method in the BSBLANClimate class. It removes the unnecessary parameter "expected_result" and simplifies the code by directly calling the service to set the temperature. The method now correctly asserts that the thermostat method is called with the correct temperature. * refactor: Add static data to async_get_config_entry_diagnostics * refactor: Add static data to async_get_config_entry_diagnostics right place * refactor: Improve error message for setting preset mode This commit updates the error message in the BSBLANClimate class when trying to set the preset mode. * refactor: Improve tests * Fix --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-09-08 08:41:54 +00:00
from unittest.mock import patch
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def setup_with_selected_platforms(
hass: HomeAssistant, config_entry: MockConfigEntry, platforms: list[Platform]
) -> None:
"""Set up the BSBLAN integration with the selected platforms."""
config_entry.add_to_hass(hass)
with patch("homeassistant.components.bsblan.PLATFORMS", platforms):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()