'Ensuring soco methods called for sonos_set_sleep_timer service.'

@mock.patch('soco.SoCo', new=SoCoMock)
@mock.patch('soco.alarms.Alarm')
@mock.patch('socket.create_connection', side_effect=socket.error())
def test_update_alarm(self, soco_mock, alarm_mock, *args):

    sonos.setup_platform(self.hass, {}, fake_add_device, {'host': '192.0.2.1'})
    device = self.hass.data[sonos.DATA_SONOS][(-1)]
    device.hass = self.hass
    alarm1 = alarms.Alarm(soco_mock)
    alarm1.configure_mock(_alarm_id='1', start_time=None, enabled=False, include_linked_zones=False, volume=100)
    with mock.patch('soco.alarms.get_alarms', return_value=[alarm1]):
        attrs = {'time': datetime.time(12, 0), 'enabled': True, 'include_linked_zones': True, 'volume': 0.3}
        device.update_alarm(alarm_id=2)
        alarm1.save.assert_not_called()
        device.update_alarm(alarm_id=1, **attrs)
        self.assertEqual(alarm1.enabled, attrs['enabled'])
        self.assertEqual(alarm1.start_time, attrs['time'])
        self.assertEqual(alarm1.include_linked_zones, attrs['include_linked_zones'])
        self.assertEqual(alarm1.volume, 30)
        alarm1.save.assert_called_once_with()
