def test_set_alarm(self, pysonos_mock, alarm_mock, *args):
     """Ensure pysonos methods called for sonos_set_sleep_timer service."""
     sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
         'host': '192.0.2.1'
     })
     device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
     device.hass = self.hass
     alarm1 = alarms.Alarm(pysonos_mock)
     alarm1.configure_mock(_alarm_id="1", start_time=None, enabled=False,
                           include_linked_zones=False, volume=100)
     with mock.patch('pysonos.alarms.get_alarms', return_value=[alarm1]):
         attrs = {
             'time': datetime.time(12, 00),
             'enabled': True,
             'include_linked_zones': True,
             'volume': 0.30,
         }
         device.set_alarm(alarm_id=2)
         alarm1.save.assert_not_called()
         device.set_alarm(alarm_id=1, **attrs)
         assert alarm1.enabled == attrs['enabled']
         assert alarm1.start_time == attrs['time']
         assert alarm1.include_linked_zones == \
             attrs['include_linked_zones']
         assert alarm1.volume == 30
         alarm1.save.assert_called_once_with()
 def test_set_alarm(self, pysonos_mock, alarm_mock, *args):
     """Ensure pysonos methods called for sonos_set_sleep_timer service."""
     sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                          {'host': '192.0.2.1'})
     entity = self.hass.data[sonos.DATA_SONOS].entities[-1]
     entity.hass = self.hass
     alarm1 = alarms.Alarm(pysonos_mock)
     alarm1.configure_mock(_alarm_id="1",
                           start_time=None,
                           enabled=False,
                           include_linked_zones=False,
                           volume=100)
     with mock.patch('pysonos.alarms.get_alarms', return_value=[alarm1]):
         attrs = {
             'time': datetime.time(12, 00),
             'enabled': True,
             'include_linked_zones': True,
             'volume': 0.30,
         }
         entity.set_alarm(alarm_id=2)
         alarm1.save.assert_not_called()
         entity.set_alarm(alarm_id=1, **attrs)
         assert alarm1.enabled == attrs['enabled']
         assert alarm1.start_time == attrs['time']
         assert alarm1.include_linked_zones == \
             attrs['include_linked_zones']
         assert alarm1.volume == 30
         alarm1.save.assert_called_once_with()
    def test_ensure_setup_discovery(self, *args):
        """Test a single device using the autodiscovery provided by HASS."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})

        entities = self.hass.data[sonos.DATA_SONOS].entities
        assert len(entities) == 1
        assert entities[0].name == 'Kitchen'
Beispiel #4
0
    def test_sonos_set_sleep_timer(self, set_sleep_timerMock, *args):
        """Ensure pysonos methods called for sonos_set_sleep_timer service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        device.set_sleep_timer(30)
        set_sleep_timerMock.assert_called_once_with(30)
    def test_sonos_clear_sleep_timer(self, set_sleep_timerMock, *args):
        """Ensure pysonos method called for sonos_clear_sleep_timer service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        entity = self.hass.data[sonos.DATA_SONOS].entities[-1]
        entity.hass = self.hass

        entity.set_sleep_timer(None)
        set_sleep_timerMock.assert_called_once_with(None)
    def test_ensure_setup_discovery(self, *args):
        """Test a single device using the autodiscovery provided by HASS."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })

        devices = list(self.hass.data[sonos.DATA_SONOS].devices)
        assert len(devices) == 1
        assert devices[0].name == 'Kitchen'
    def test_sonos_clear_sleep_timer(self, set_sleep_timerMock, *args):
        """Ensure pysonos method called for sonos_clear_sleep_timer service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        device.set_sleep_timer(None)
        set_sleep_timerMock.assert_called_once_with(None)
    def test_sonos_set_sleep_timer(self, set_sleep_timerMock, *args):
        """Ensure pysonos methods called for sonos_set_sleep_timer service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        entity = self.hass.data[sonos.DATA_SONOS].entities[-1]
        entity.hass = self.hass

        entity.set_sleep_timer(30)
        set_sleep_timerMock.assert_called_once_with(30)
Beispiel #9
0
    def test_sonos_snapshot(self, snapshotMock, *args):
        """Ensure pysonos methods called for sonos_snapshot service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        snapshotMock.return_value = True
        device.snapshot()
        assert snapshotMock.call_count == 1
        assert snapshotMock.call_args == mock.call()
    def test_sonos_snapshot(self, snapshotMock, *args):
        """Ensure pysonos methods called for sonos_snapshot service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        snapshotMock.return_value = True
        device.snapshot()
        assert snapshotMock.call_count == 1
        assert snapshotMock.call_args == mock.call()
Beispiel #11
0
    def test_sonos_snapshot(self, snapshotMock, *args):
        """Ensure pysonos methods called for sonos_snapshot service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        entities = self.hass.data[sonos.DATA_SONOS].entities
        entity = entities[-1]
        entity.hass = self.hass

        snapshotMock.return_value = True
        entity.soco.group = mock.MagicMock()
        entity.soco.group.members = [e.soco for e in entities]
        sonos.SonosEntity.snapshot_multi(entities, True)
        assert snapshotMock.call_count == 1
        assert snapshotMock.call_args == mock.call()
    def test_sonos_snapshot(self, snapshotMock, *args):
        """Ensure pysonos methods called for sonos_snapshot service."""
        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        entities = self.hass.data[sonos.DATA_SONOS].entities
        entity = entities[-1]
        entity.hass = self.hass

        snapshotMock.return_value = True
        entity.soco.group = mock.MagicMock()
        entity.soco.group.members = [e.soco for e in entities]
        sonos.SonosEntity.snapshot_multi(entities, True)
        assert snapshotMock.call_count == 1
        assert snapshotMock.call_args == mock.call()
Beispiel #13
0
    def test_sonos_restore(self, restoreMock, *args):
        """Ensure pysonos methods called for sonos_restore service."""
        from pysonos.snapshot import Snapshot

        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        restoreMock.return_value = True
        device._snapshot_coordinator = mock.MagicMock()
        device._snapshot_coordinator.soco_device = SoCoMock('192.0.2.17')
        device._soco_snapshot = Snapshot(device._player)
        device.restore()
        assert restoreMock.call_count == 1
        assert restoreMock.call_args == mock.call(False)
    def test_sonos_restore(self, restoreMock, *args):
        """Ensure pysonos methods called for sonos_restore service."""
        from pysonos.snapshot import Snapshot

        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
        device.hass = self.hass

        restoreMock.return_value = True
        device._snapshot_coordinator = mock.MagicMock()
        device._snapshot_coordinator.soco_device = SoCoMock('192.0.2.17')
        device._soco_snapshot = Snapshot(device._player)
        device.restore()
        assert restoreMock.call_count == 1
        assert restoreMock.call_args == mock.call(False)
    def test_sonos_restore(self, restoreMock, *args):
        """Ensure pysonos methods called for sonos_restore service."""
        from pysonos.snapshot import Snapshot

        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass),
                             {'host': '192.0.2.1'})
        entities = self.hass.data[sonos.DATA_SONOS].entities
        entity = entities[-1]
        entity.hass = self.hass

        restoreMock.return_value = True
        entity._snapshot_group = mock.MagicMock()
        entity._snapshot_group.members = [e.soco for e in entities]
        entity._soco_snapshot = Snapshot(entity.soco)
        run_coroutine_threadsafe(
            sonos.SonosEntity.restore_multi(self.hass, entities, True),
            self.hass.loop).result()
        assert restoreMock.call_count == 1
        assert restoreMock.call_args == mock.call()
    def test_sonos_restore(self, restoreMock, *args):
        """Ensure pysonos methods called for sonos_restore service."""
        from pysonos.snapshot import Snapshot

        sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
            'host': '192.0.2.1'
        })
        entities = self.hass.data[sonos.DATA_SONOS].entities
        entity = entities[-1]
        entity.hass = self.hass

        restoreMock.return_value = True
        entity._snapshot_group = mock.MagicMock()
        entity._snapshot_group.members = [e.soco for e in entities]
        entity._soco_snapshot = Snapshot(entity.soco)
        run_coroutine_threadsafe(
            sonos.SonosEntity.restore_multi(self.hass, entities, True),
            self.hass.loop).result()
        assert restoreMock.call_count == 1
        assert restoreMock.call_args == mock.call()
 def test_ensure_setup_sonos_discovery(self, *args):
     """Test a single device using the autodiscovery provided by Sonos."""
     sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass))
     entities = self.hass.data[sonos.DATA_SONOS].entities
     assert len(entities) == 1
     assert entities[0].name == 'Kitchen'
Beispiel #18
0
 def test_ensure_setup_sonos_discovery(self, *args):
     """Test a single device using the autodiscovery provided by Sonos."""
     sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass))
     devices = list(self.hass.data[sonos.DATA_SONOS].devices)
     assert len(devices) == 1
     assert devices[0].name == 'Kitchen'