def test_play_everywhere(self, mocked_soundtouch_device, mocked_status,
                             mocked_volume, mocked_create_zone):
        """Test play everywhere."""
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
        all_devices[0].entity_id = "media_player.entity_1"
        all_devices[1].entity_id = "media_player.entity_2"
        assert mocked_soundtouch_device.call_count == 2
        assert mocked_status.call_count == 2
        assert mocked_volume.call_count == 2

        # one master, one slave => create zone
        self.hass.services.call(soundtouch.DOMAIN,
                                soundtouch.SERVICE_PLAY_EVERYWHERE,
                                {"master": "media_player.entity_1"}, True)
        assert mocked_create_zone.call_count == 1

        # unknown master. create zone is must not be called
        self.hass.services.call(soundtouch.DOMAIN,
                                soundtouch.SERVICE_PLAY_EVERYWHERE,
                                {"master": "media_player.entity_X"}, True)
        assert mocked_create_zone.call_count == 1

        # no slaves, create zone must not be called
        all_devices.pop(1)
        self.hass.services.call(soundtouch.DOMAIN,
                                soundtouch.SERVICE_PLAY_EVERYWHERE,
                                {"master": "media_player.entity_1"}, True)
        assert mocked_create_zone.call_count == 1
Example #2
0
 def test_media_commands(self, mocked_sountouch_device):
     """Test supported media commands."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].supported_media_commands, 1469)
    def test_create_zone(self, mocked_sountouch_device, mocked_status,
                         mocked_volume, mocked_create_zone):
        """Test creating a zone."""
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        soundtouch.DEVICES[0].entity_id = "entity_1"
        soundtouch.DEVICES[1].entity_id = "entity_2"
        self.assertEqual(mocked_sountouch_device.call_count, 2)
        self.assertEqual(mocked_status.call_count, 2)
        self.assertEqual(mocked_volume.call_count, 2)

        # one master, one slave => create zone
        service = MockService("entity_1", ["entity_2"])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)

        # unknown master. create zone is must not be called
        service = MockService("entity_X", [])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)

        # no slaves, create zone must not be called
        soundtouch.DEVICES.pop(1)
        service = MockService("entity_1", [])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)
Example #4
0
 def test_media_commands(self, mocked_soundtouch_device):
     """Test supported media commands."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(all_devices[0].supported_features, 17853)
    def test_remove_zone_slave(self, mocked_sountouch_device, mocked_status,
                               mocked_volume, mocked_remove_zone_slave):
        """Test removing a slave from a zone."""
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        soundtouch.setup_platform(self.hass,
                                  default_component(),
                                  mock.MagicMock())
        soundtouch.DEVICES[0].entity_id = "entity_1"
        soundtouch.DEVICES[1].entity_id = "entity_2"
        self.assertEqual(mocked_sountouch_device.call_count, 2)
        self.assertEqual(mocked_status.call_count, 2)
        self.assertEqual(mocked_volume.call_count, 2)

        # remove one slave
        service = MockService("entity_1", ["entity_2"])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)

        # unknown master. remove zone slave is not called
        service = MockService("entity_X", ["entity_2"])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)

        # no slave to add, add zone slave is not called
        service = MockService("entity_1", [])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)
Example #6
0
    def test_create_zone(self, mocked_sountouch_device, mocked_status,
                         mocked_volume, mocked_create_zone):
        """Test creating a zone."""
        soundtouch.setup_platform(self.hass, default_component(),
                                  mock.MagicMock())
        soundtouch.setup_platform(self.hass, default_component(),
                                  mock.MagicMock())
        soundtouch.DEVICES[0].entity_id = "entity_1"
        soundtouch.DEVICES[1].entity_id = "entity_2"
        self.assertEqual(mocked_sountouch_device.call_count, 2)
        self.assertEqual(mocked_status.call_count, 2)
        self.assertEqual(mocked_volume.call_count, 2)

        # one master, one slave => create zone
        service = MockService("entity_1", ["entity_2"])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)

        # unknown master. create zone is must not be called
        service = MockService("entity_X", [])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)

        # no slaves, create zone must not be called
        soundtouch.DEVICES.pop(1)
        service = MockService("entity_1", [])
        soundtouch.create_zone_service(service)
        self.assertEqual(mocked_create_zone.call_count, 1)
Example #7
0
    def test_remove_zone_slave(self, mocked_sountouch_device, mocked_status,
                               mocked_volume, mocked_remove_zone_slave):
        """Test removing a slave from a zone."""
        soundtouch.setup_platform(self.hass, default_component(),
                                  mock.MagicMock())
        soundtouch.setup_platform(self.hass, default_component(),
                                  mock.MagicMock())
        soundtouch.DEVICES[0].entity_id = "entity_1"
        soundtouch.DEVICES[1].entity_id = "entity_2"
        self.assertEqual(mocked_sountouch_device.call_count, 2)
        self.assertEqual(mocked_status.call_count, 2)
        self.assertEqual(mocked_volume.call_count, 2)

        # remove one slave
        service = MockService("entity_1", ["entity_2"])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)

        # unknown master. remove zone slave is not called
        service = MockService("entity_X", ["entity_2"])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)

        # no slave to add, add zone slave is not called
        service = MockService("entity_1", [])
        soundtouch.remove_zone_slave(service)
        self.assertEqual(mocked_remove_zone_slave.call_count, 1)
 def test_media_commands(self, mocked_sountouch_device):
     """Test supported media commands."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].supported_media_commands, 17853)
 def test_media_commands(self, mocked_soundtouch_device):
     """Test supported media commands."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert all_devices[0].supported_features == 17853
Example #10
0
 def test_ensure_setup_config(self, mocked_sountouch_device):
     """Test setup OK."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     # soundtouch.DEVICES[0].entity_id = 'entity_1'
     self.assertEqual(len(soundtouch.DEVICES), 1)
     self.assertEqual(soundtouch.DEVICES[0].name, 'soundtouch')
     self.assertEqual(soundtouch.DEVICES[0].config['port'], 8090)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
Example #11
0
 def test_ensure_setup_config(self, mocked_soundtouch_device):
     """Test setup OK with custom config."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(len(all_devices), 1)
     self.assertEqual(all_devices[0].name, 'soundtouch')
     self.assertEqual(all_devices[0].config['port'], 8090)
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
Example #12
0
 def test_playing_unknown_media(self, mocked_sountouch_device,
                                mocked_status, mocked_volume):
     """Test playing media info."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].media_title, None)
Example #13
0
 def test_get_volume_level(self, mocked_sountouch_device, mocked_status,
                           mocked_volume):
     """Test volume level."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].volume_level, 0.12)
Example #14
0
 def test_is_muted(self, mocked_sountouch_device, mocked_status,
                   mocked_volume):
     """Test device volume is muted."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].is_volume_muted, True)
Example #15
0
 def test_get_state_pause(self, mocked_sountouch_device, mocked_status,
                          mocked_volume):
     """Test state device is paused."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].state, STATE_PAUSED)
 def test_get_volume_level(self, mocked_sountouch_device, mocked_status,
                           mocked_volume):
     """Test volume level."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].volume_level, 0.12)
 def test_playing_unknown_media(self, mocked_sountouch_device,
                                mocked_status, mocked_volume):
     """Test playing media info."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].media_title, None)
 def test_ensure_setup_config(self, mocked_sountouch_device):
     """Test setup OK."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     # soundtouch.DEVICES[0].entity_id = 'entity_1'
     self.assertEqual(len(soundtouch.DEVICES), 1)
     self.assertEqual(soundtouch.DEVICES[0].name, 'soundtouch')
     self.assertEqual(soundtouch.DEVICES[0].config['port'], 8090)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
Example #19
0
 def test_get_state_off(self, mocked_soundtouch_device, mocked_status,
                        mocked_volume):
     """Test state device is off."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(all_devices[0].state, STATE_OFF)
Example #20
0
 def test_is_muted(self, mocked_soundtouch_device, mocked_status,
                   mocked_volume):
     """Test device volume is muted."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(all_devices[0].is_volume_muted, True)
Example #21
0
 def test_play_pause_play(self, mocked_sountouch_device, mocked_status,
                          mocked_volume, mocked_play_pause):
     """Test play/pause."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].media_play_pause()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_play_pause.call_count, 1)
Example #22
0
 def test_mute(self, mocked_sountouch_device, mocked_status, mocked_volume,
               mocked_mute):
     """Test mute volume."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].mute_volume(None)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_mute.call_count, 1)
Example #23
0
 def test_volume_down(self, mocked_sountouch_device, mocked_status,
                      mocked_volume, mocked_volume_down):
     """Test volume down."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].volume_down()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_volume_down.call_count, 1)
Example #24
0
 def test_should_turn_on(self, mocked_sountouch_device, mocked_status,
                         mocked_volume, mocked_power_on):
     """Test device is turned on."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].turn_on()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_power_on.call_count, 1)
 def test_get_state_pause(self, mocked_sountouch_device, mocked_status,
                          mocked_volume):
     """Test state device is paused."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].state, STATE_PAUSED)
 def test_is_muted(self, mocked_sountouch_device, mocked_status,
                   mocked_volume):
     """Test device volume is muted."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(soundtouch.DEVICES[0].is_volume_muted, True)
Example #27
0
 def test_get_volume_level(self, mocked_soundtouch_device, mocked_status,
                           mocked_volume):
     """Test volume level."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(all_devices[0].volume_level, 0.12)
 def test_ensure_setup_config(self, mocked_sountouch_device):
     """Test setup OK with custom config."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(len(all_devices), 1)
     self.assertEqual(all_devices[0].name, 'soundtouch')
     self.assertEqual(all_devices[0].config['port'], 8090)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
 def test_ensure_setup_config(self, mocked_soundtouch_device):
     """Test setup OK with custom config."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert len(all_devices) == 1
     assert all_devices[0].name == 'soundtouch'
     assert all_devices[0].config['port'] == 8090
     assert mocked_soundtouch_device.call_count == 1
 def test_get_state_off(self, mocked_sountouch_device, mocked_status,
                        mocked_volume):
     """Test state device is off."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(all_devices[0].state, STATE_OFF)
Example #31
0
 def test_mute(self, mocked_soundtouch_device, mocked_status, mocked_volume,
               mocked_mute):
     """Test mute volume."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].mute_volume(None)
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_mute.call_count, 1)
Example #32
0
 def test_pause(self, mocked_soundtouch_device, mocked_status,
                mocked_volume, mocked_pause):
     """Test pause command."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].media_pause()
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_pause.call_count, 1)
 def test_play_pause_play(self, mocked_sountouch_device, mocked_status,
                          mocked_volume, mocked_play_pause):
     """Test play/pause."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].media_play_pause()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_play_pause.call_count, 1)
 def test_mute(self, mocked_sountouch_device, mocked_status, mocked_volume,
               mocked_mute):
     """Test mute volume."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].mute_volume(None)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_mute.call_count, 1)
 def test_volume_down(self, mocked_sountouch_device, mocked_status,
                      mocked_volume, mocked_volume_down):
     """Test volume down."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].volume_down()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_volume_down.call_count, 1)
 def test_should_turn_on(self, mocked_sountouch_device, mocked_status,
                         mocked_volume, mocked_power_on):
     """Test device is turned on."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     soundtouch.DEVICES[0].turn_on()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_power_on.call_count, 1)
Example #37
0
 def test_update(self, mocked_soundtouch_device, mocked_status,
                 mocked_volume):
     """Test update device state."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     self.hass.data[soundtouch.DATA_SOUNDTOUCH][0].update()
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 2)
Example #38
0
 def test_play_media_url(self, mocked_soundtouch_device, mocked_status,
                         mocked_volume, mocked_play_url):
     """Test play preset 1."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 1)
     all_devices[0].play_media('MUSIC', "http://fqdn/file.mp3")
     mocked_play_url.assert_called_with("http://fqdn/file.mp3")
 def test_is_muted(self, mocked_soundtouch_device, mocked_status,
                   mocked_volume):
     """Test device volume is muted."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert all_devices[0].is_volume_muted is True
Example #40
0
 def test_should_turn_off(self, mocked_soundtouch_device, mocked_status,
                          mocked_volume, mocked_power_off):
     """Test device is turned off."""
     soundtouch.setup_platform(self.hass, default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].turn_off()
     self.assertEqual(mocked_soundtouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_power_off.call_count, 1)
 def test_get_volume_level(self, mocked_soundtouch_device, mocked_status,
                           mocked_volume):
     """Test volume level."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert all_devices[0].volume_level == 0.12
 def test_get_state_pause(self, mocked_soundtouch_device, mocked_status,
                          mocked_volume):
     """Test state device is paused."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert all_devices[0].state == STATE_PAUSED
 def test_playing_unknown_media(self, mocked_soundtouch_device,
                                mocked_status, mocked_volume):
     """Test playing media info."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert all_devices[0].media_title is None
 def test_play_media_url(self, mocked_soundtouch_device, mocked_status,
                         mocked_volume, mocked_play_url):
     """Test play preset 1."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     all_devices[0].play_media('MUSIC', "http://fqdn/file.mp3")
     mocked_play_url.assert_called_with("http://fqdn/file.mp3")
 def test_play_pause_play(self, mocked_soundtouch_device, mocked_status,
                          mocked_volume, mocked_play_pause):
     """Test play/pause."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].media_play_pause()
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 2
     assert mocked_volume.call_count == 1
     assert mocked_play_pause.call_count == 1
 def test_mute(self, mocked_soundtouch_device, mocked_status, mocked_volume,
               mocked_mute):
     """Test mute volume."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].mute_volume(None)
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 2
     assert mocked_mute.call_count == 1
 def test_set_volume_level(self, mocked_soundtouch_device, mocked_status,
                           mocked_volume, mocked_set_volume):
     """Test set volume level."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].set_volume_level(0.17)
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 2
     mocked_set_volume.assert_called_with(17)
 def test_volume_down(self, mocked_soundtouch_device, mocked_status,
                      mocked_volume, mocked_volume_down):
     """Test volume down."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].volume_down()
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 2
     assert mocked_volume_down.call_count == 1
 def test_should_turn_on(self, mocked_soundtouch_device, mocked_status,
                         mocked_volume, mocked_power_on):
     """Test device is turned on."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].turn_on()
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 2
     assert mocked_volume.call_count == 1
     assert mocked_power_on.call_count == 1
 def test_update(self, mocked_soundtouch_device, mocked_status,
                 mocked_volume):
     """Test update device state."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     assert mocked_soundtouch_device.call_count == 1
     assert mocked_status.call_count == 1
     assert mocked_volume.call_count == 1
     self.hass.data[soundtouch.DATA_SOUNDTOUCH][0].update()
     assert mocked_status.call_count == 2
     assert mocked_volume.call_count == 2
 def test_volume_up(self, mocked_sountouch_device, mocked_status,
                    mocked_volume, mocked_volume_up):
     """Test volume up."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].volume_up()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     self.assertEqual(mocked_volume_up.call_count, 1)
 def test_pause(self, mocked_sountouch_device, mocked_status, mocked_volume,
                mocked_pause):
     """Test pause command."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].media_pause()
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 2)
     self.assertEqual(mocked_volume.call_count, 1)
     self.assertEqual(mocked_pause.call_count, 1)
 def test_set_volume_level(self, mocked_sountouch_device, mocked_status,
                           mocked_volume, mocked_set_volume):
     """Test set volume level."""
     soundtouch.setup_platform(self.hass,
                               default_component(),
                               mock.MagicMock())
     all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
     all_devices[0].set_volume_level(0.17)
     self.assertEqual(mocked_sountouch_device.call_count, 1)
     self.assertEqual(mocked_status.call_count, 1)
     self.assertEqual(mocked_volume.call_count, 2)
     mocked_set_volume.assert_called_with(17)