async def test_async_set_percentage_non_zero(hass, mock_device_wrapper): """Test setting percentage speed.""" device = build_purifier(hass, mock_device_wrapper) device.async_turn_off = AsyncMock() await device.async_set_percentage(20) assert device.async_turn_off.call_count == 0 assert mock_device_wrapper.async_set_speed.call_count == 1
async def test_async_turn_on_preset(hass, mock_device_wrapper): """Test turning on.""" device = build_purifier(hass, mock_device_wrapper) device.async_set_percentage = AsyncMock() await device.async_turn_on(None, None, PRESET_MODE_MANUAL) assert device.async_set_percentage.call_count == 0 assert mock_device_wrapper.async_set_preset_mode.call_count == 1 assert mock_device_wrapper.async_turn_on.call_count == 0
async def test_plasma_toggle(hass, mock_device_wrapper, is_plasma_on): """Test pasma toggle operation.""" type(mock_device_wrapper).is_plasma_on = is_plasma_on device = build_purifier(hass, mock_device_wrapper) await device.async_plasmawave_toggle() if is_plasma_on: assert mock_device_wrapper.async_plasmawave_off.call_count == 1 assert mock_device_wrapper.async_plasmawave_on.call_count == 0 else: assert mock_device_wrapper.async_plasmawave_off.call_count == 0 assert mock_device_wrapper.async_plasmawave_on.call_count == 1
async def test_fan_operations(hass, mock_device_wrapper, args): """Test other fan operations.""" mocked_method = AsyncMock() method = args[0] with patch.object(mock_device_wrapper, method, mocked_method): device = build_purifier(hass, mock_device_wrapper) if len(args) == 2: await getattr(device, method)(args[1]) else: await getattr(device, method)() assert mocked_method.call_count == 1